Microsoft Internet Explorer, Adobe Acrobat's web-plugin, and Apache's mod_deflate

For the past year this has been a problem with the server this website has been hosted on; it was the strangest thing ever that I could not understand. If you tried to view a PDF file you placed on the web server with Microsoft Internet Explorer with Adobe’s Acrobat web plugin on Windows (a very common configuration), you would get an error about the PDF being corrupt and that it could not be opened.

It worked everywhere else: Mozilla Firefox and the Adobe Acrobat web plugin on Windows, with zero problems with any combination of browser and PDF viewer on Linux and OS X.

Apache 2.0’s documentation on mod_deflate suggests to compress everything except image files:

SetOutputFilter DEFLATE SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary

The problem with this: there are many filetypes left out that don’t compress well, and can cause problems–like PDFs combined with Internet Explorer and Adobe’s Acrobat plugin.

The solution, add the rule:

SetEnvIfNoCase Request_URI .(?:pdf)$ no-gzip dont-vary

This prevents PDF files from being compressed with mod_deflate. It’s also useful to add such files as MP3s, zips, and rars.

Like this article? Please support my writing! Flattr my blog (see my thoughts on Flattr), tip me via PayPal, or send me an item from my Amazon wish list.