I have apache 2.2.11 installed on my server and I have been trying to decrease the load time of my website pages based on the advice from the yslow firefox plugin.
I have configured gzip and etag and some of its other suggestions fine but I have noticed in the header for my css files etag is being appended with the text gzip.
Does anyone know why and how to get round this?
Header from my server
Date Sun, 07 Jun 2009 10:40:57 GMT
Server Apache/2.2.11 (Fedora)
Last-Modified Sun, 31 May 2009 15:06:38 GMT
Etag "3b4-46b36a802bb80"-gzip
Accept-Ranges bytes
Cache-Control max-age=2592000
Expires Tue, 07 Jul 2009 10:40:57 GMT
Vary Accept-Encoding
Content-Encoding gzip
Content-Length 530
Connection close
Content-Type text/css
The same code on my hosted package uses an older version of apache and doesn't have the same problem. Could this just be an apache bug?
Header from my hosting package
Date Sun, 07 Jun 2009 10:48:26 GMT
Server Apache/2.0.63 (FreeBSD) mod_python/3.3.1 Python/2.5.1 PHP/5.2.6 with Suhosin-Patch mod_fastcgi/2.4.6 mod_ssl/2.0.63 OpenSSL/0.9.7e-p1 DAV/2 mod_perl/2.0.4 Perl/v5.8.8
Last-Modified Sat, 21 Feb 2009 13:54:52 GMT
Etag "3b4-1d104300"
Accept-Ranges bytes
Cache-Control max-age=2592000
Expires Tue, 07 Jul 2009 10:48:26 GMT
Vary Accept-Encoding
Content-Encoding gzip
Content-Length 530
Connection close
Content-Type text/css
Answer
Here's an ideal .htaccess that both compresses and sets sutiable expire headers.
# 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
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 216000 seconds"
ExpiresByType application/x-javascript "access plus 216000 seconds"
ExpiresByType text/html "access plus 600 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
Header set Cache-Control "max-age=2592000, public"
Header set Cache-Control "max-age=604800, public"
Header set Cache-Control "max-age=216000, private"
Header set Cache-Control "max-age=600, private, must-revalidate"
Header unset ETag
FileETag None
Header unset Last-Modified
The following article covers what it does and also talks about compression:
http://www.samaxes.com/2009/01/06/more-on-compressing-and-caching-your-site-with-htaccess/
Hope that helps.
No comments:
Post a Comment