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?
Asked
Active
Viewed 748 times
2 Answers
4
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…

ColtonCat
- 738
- 3
- 7
-
3nginx has add_header directive ( http://wiki.nginx.org/NginxHttpHeadersModule#add_header ). You can place it under `location ~ \.pdf$` – SaveTheRbtz Sep 11 '09 at 07:01
2
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...

SaveTheRbtz
- 5,691
- 4
- 32
- 45