Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

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...

share|improve this answer
add comment

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…

share|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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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