views:

447

answers:

2

I enabled mod_deflate on Apache 2 on an Ubuntu machine and noticed that my browser doesn't cache the compressed file types on page refreshes. I used firebug's net settings to check this and verified on another computer.

Under mod_deflate if I compress css and js files, the browser makes a request each time.

If I turn off mod_deflate, the browser gets a 304 for the css and js files. The net effect is that the pages load faster on a refresh if I don't have mod_deflate enabled.

Could one of the other modules I have turned on be causing this? Is there some sort of cache setting in Apache that I'm not setting correctly?

My mods-enabled directory: alias.conf
authz_default.load
autoindex.conf
deflate.load
mime.conf
php5.conf
setenvif.load
alias.load
authz_groupfile.load
autoindex.load
dir.conf
mime.load
php5.load
ssl.conf
auth_digest.load
authz_host.load
cgi.load
dir.load
negotiation.conf
rewrite.load
ssl.load
authn_file.load
authz_user.load
deflate.conf
env.load
negotiation.load
setenvif.conf

A: 

I thought I answered this before...didn't get posted though. Sorry if it ends up being a double post.

Turns out that it was etags that were causing the problem. I'm not sure why but when we turned off etags, the browser started caching things correctly. Search for FileETags on Google.

Now, I'm not sure why turning etags off would do this...if anyone knows, please do post to this thread. Thanks!

A: 

It's actually a bug of Apache regarding Etags with gzip:

https://issues.apache.org/bugzilla/show%5Fbug.cgi?id=45023

Turning ETags works works but there is better workaround:

<IfModule mod_headers.c>
    RequestHeader  edit "If-None-Match" "^(.*)-gzip$" "$1"
    Header  edit "ETag" "^(.*[^g][^z][^i][^p])$" "$1-gzip"
</IfModule>
krewetka