How do I disable compression for PDFs using Nginx? Related question, how do I stop Adobe Reader from automatically opening the PDF, instead of saving it to the hard drive?

link|improve this question

67% accept rate
feedback

2 Answers

up vote 2 down vote accepted

First, nginx enables gzip only for text/html by default so there is no compression when serving PDFs You can setup types you want to gzip (remember that for text/html is on always) by:

gzip_types text/css text/js text/xml;

Second is client side. I can't possibly think a way other then to told user to right-click and save to...

link|improve this answer
feedback

On the second part, you just have to set the Content-Disposition header to supply a preferred filename and the browser will display a save-file dialog.

I don't know how you would cause Nginx to do that, in php I just use this code:

header('Content-Disposition: attachment; filename="wootwoot.pdf"');

Be sure to use this BEFORE php outputs any data…

link|improve this answer
3  
nginx has add_header directive ( wiki.nginx.org/NginxHttpHeadersModule#add_header ). You can place it under location ~ \.pdf$ – SaveTheRbtz Sep 11 '09 at 7:01
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.