Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We have a Apache 2.2 with mod_cache and mod_deflate among other modules. The problem is that if we append Vary header as in Apache documentation...

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary

... we end up having copy of the served resource for each user agent variation in our cache. This wastes disk space and lowers the hit rate.

So, what is the preferred solution for this problem? Ditch the Vary header and compress only "safe" resources like plain html?

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

The reason for setting the header to vary by user agent is that Apache's recommended configuration for mod_deflate serves uncompressed versions of some content to Netscape 4 users. There are probably few enough Netscape 4 users now that you can just serve compressed content to all browsers that claim to support it, and not vary by user agent.

So instead of the recommended configuration:

<Location />
# 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
# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location>

You can just have:

<Location />
# Insert filter
SetOutputFilter DEFLATE

# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
</Location>
share|improve this answer
    
Netscape 4.0x was released in 1998, and even Microsoft celebrated the death of IE6. I agree it's time we move on :) –  Hank Feb 28 '12 at 20:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.