While watching some web access logs recently, I noticed that Internet Explorer was not properly caching images. So for common images shared on all the pages of the server, Internet Explorer was downloading the image over and over again. Firefox was properly caching them, but since the majority of the internet still surfs via IE, this problem was wasting a lot of bandwidth.
After some research, I discovered that this problem was the result of using
mod_gzip on the server. mod_gzip is an Apache module that compresses web page data before it is sent to the browser, thereby saving bandwidth. You typically only use it on HTML pages since graphics don't compress well. Even though my mod_gzip instructions were telling it not to compress images, it was still doing something to the HTTP headers of those files (sending a "Vary" entry). It turns out that this was the cause of IE not caching the images. So my savings in HTML page bandwidth was probably spent in image bandwidth.
I found a solution in
this discussion, and it seemed to work for me. I added this to my Apache configuration:
<Files ~ "\.(jpg|gif|png)$">
mod_gzip_send_vary Off
</Files>
Now I'll get to see how much bandwidth I can really save with mod_gzip!
Update 2006-05-07: Lately I've been playing around with using PHP to dynamically provide images from a file cache. In that case, to get web caching to work properly, you'll need to disable the mod_gzip_send_vary on the PHP filename that generates your images, as the example above only accounts for image filenames.