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

Tags: •  • 

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.


Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text.
  • Images can be added to this post.
  • You may use [inline:xx] tags to display uploaded files or images inline.
More information about formatting options