I have spent the last couple of hours grappling with this problem, and having finally got to the bottom of it I’d thought I’d share my solution.
Ok, so the problem was that a PHP script which prepared a download (in this case a .zip) from Elgg’s file store was working fine in Firefox but producing a corrupt archive in IE.
On examining the headers being sent and received I was able to establish that there were two main issues going on:
- The code which only permits compression for text mime types was being ignored.
The reason, obvious with hindsight but not at the time, was this:
The file was being served by a script, this script modifies the mimetype via header. However, apache was determining whether to compress the file or not based on the initial mimetype of the script – which of course was text/html!
Once I figured that out, it was fairly simple to solve. I added the following lines to the mod_deflate settings in the .htaccess file.
SetEnvIfNoCase Request_URI action\/* no-gzip dont-vary
SetEnvIfNoCase Request_URI actions\/* no-gzip dont-vary
These lines turn off gzip compression for all actions, while leaving compression running for all other files. This solution is better than turning compression off altogether but it is not ideal, for one if you attempt a script download from anywhere but an Elgg action (which really you shouldn’t be), you will need to modify .htaccess yourself.
Any better solutions welcome!