httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Johnson <...@indietorrent.org>
Subject [users@httpd] Are gzip-compression and caching mutually exclusive in Apache?
Date Thu, 03 Oct 2013 19:43:32 GMT
Hello,

I'm wondering if it is possible to gzip-compress response bodies while
at the same time allowing the user-agent (Web browser, in this case) to
cache the responses.

I am using Apache 2.4.

I set up client-side caching with the following, which functions as
expected:

######################################################################
<IfModule mod_headers.c>
  <FilesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$">
    Header set Cache-Control "max-age=2592000, public"
  </FilesMatch>
  <FilesMatch "\\.(css)$">
    Header set Cache-Control "max-age=604800, public"
  </FilesMatch>
  <FilesMatch "\\.(js)$">
    Header set Cache-Control "max-age=216000, private"
  </FilesMatch>
  <FilesMatch "\\.(xml|txt)$">
    Header set Cache-Control "max-age=216000, public, must-revalidate"
  </FilesMatch>
  <FilesMatch "\\.(html|htm|php)$">
    Header set Cache-Control "max-age=1, private, must-revalidate"
  </FilesMatch>
</IfModule>

<IfModule mod_expires.c>
	ExpiresActive on
	
	ExpiresDefault "access plus 1 seconds"
	
	ExpiresByType image/jpg "access plus 60 days"
	ExpiresByType image/png "access plus 60 days"
	ExpiresByType image/gif "access plus 60 days"
	ExpiresByType image/jpeg "access plus 60 days"
	
	ExpiresByType text/css "access plus 1 week"
	
	ExpiresByType image/x-icon "access plus 1 month"
	
	ExpiresByType application/pdf "access plus 1 month"
	ExpiresByType audio/x-wav "access plus 1 month"
	ExpiresByType audio/mpeg "access plus 1 month"
	ExpiresByType video/mpeg "access plus 1 month"
	ExpiresByType video/mp4 "access plus 1 month"
	ExpiresByType video/quicktime "access plus 1 month"
	ExpiresByType video/x-ms-wmv "access plus 1 month"
	ExpiresByType application/x-shockwave-flash "access 1 month"
	
	ExpiresByType text/javascript "access plus 1 week"
	ExpiresByType application/x-javascript "access plus 1 week"
	ExpiresByType application/javascript "access plus 1 week"
</IfModule>
######################################################################


But as soon as I try to gzip-compress the content with the following,
the Web-browser no longer caches the responses:


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


The responses are indeed gzip-compressed, but not cached.

Are gzip-compression and caching mutually exclusive in Apache? Or am I
doing something silly?

Thanks for any pointers!

-Ben

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message