Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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
nginx has add_header directive ( ). You can place it under location ~ \.pdf$ – SaveTheRbtz Sep 11 '09 at 7:01

Your Answer


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.