Mime type woes hopefully solved
So some of you have pointed out to me that downloading a tar.gz file from my site through a browser like Firefox never seems to work well- I think I have finally fixed the problem. The odd part was that using a command line too like wget would work just fine. It all comes down to the .htaccess file.
Options +ExecCGI
Options +FollowSymLinks
AddType application/x-tar .tgz
AddType text/plain .c
AddType text/plain .h
ExpiresActive On
ExpiresDefault "access plus 15 minutes"
ExpiresByType image/gif "access plus 1 hours"
ExpiresByType image/png "access plus 1 hours"
ExpiresByType image/jpeg "access plus 1 hours"
ExpiresByType image/x-icon "access plus 1 hours"
ExpiresByType application/x-javascript "access plus 15 minutes"
ExpiresByType text/css "access plus 1 hours"
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE\s6 no-gzip
BrowserMatch \bMSIE\s7 !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png|pdf|swf|ipk)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \
\.(?:exe|tar|t?gz|zip|t?bz2|sit|rar)$ no-gzip dont-vary
Header append Vary User-Agent env=!dont-vary
I had everything in this file except one line, which is the SetEnvIfNoCase
condition for exe, tar, tgz, etc. files. Because I wasn’t excluding these common binary formats from the DEFLATE filter, the Transfer-encoding:
HTTP header was getting set to chunked, which seemed to break all sorts of stuff (but since wget did not treat this header the same, it worked fine).
Long story short- it should be all better now. Send me an email if I’m wrong.
Tags
See Also
- Moved to Slicehost - February 22, 2009
- Getting Django running on Dreamhost - July 23, 2007