I know it’s not recommended to gzip images (not sure exactly why though) so I used this code in the httpd config file to gzip everything besides images
[code]
Insert filter
SetOutputFilter DEFLATE
Netscape 4.x has some problems…
BrowserMatch ^Mozilla/4 gzip-only-text/html
Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4.0[678] no-gzip
MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
the above regex won’t work. You can use the following
Everything seems to be working fine, however; I just noticed that images with query strings (like /sample.php?id=123456.jpg) are in fact being gziped (See Results)
You shouldn’t gzip images because they will actually end up larger - they are already compressed by algorithms at least as good as gzip.
I’m a little curious why you have gzip enabled on everything by default and then choose to disable it under certain circumstances. I’m used to seeing it enabled by mime type:
using the code you wrote above didn’t work first in httpd config, I changed its location to go after LoadModule deflate_module modules/mod_deflate.so (below all LoadModules) and it works fine now!
Thanks
if I use the code you provided above; should a file like this “/sample.php?id=file-name.jpg” not be gzipped?
I tried it but it still gzips everything:huh:
it’s obviously not being treated like a regular jpg file, because if it was it would have not been gzipped even with my original code
but live headers shows it as a regular image/jpeg
Any chance your php code is doing the gzip? Just stretching here because the sample I use doesn’t gzip images when I use it but something else is going on since your images are being served from php.
we do not gzip with php, the images are in a folder like this /images/12345.jpg then being modified on the fly with php (adding watermark/resizing/etc.) and called with the php ?id=12345.jpg which serves the modified version