I serve pre-compressed CSS and JS files on my site, and IE6-8 and FF is working perfectly with my .htaccess file.
# Compressed files
RewriteCond %{HTTP:Accept-Encoding} .*gzip.*
AddEncoding x-gzip .gz
AddType application/x-javascript .gz
AddType text/css .gz
I call the files with the .gz extension already [example]:
<link rel="stylesheet" type="text/css" media="all" href="css/layout.css.gz" />
So why is this breaks in google Chrome?
Thanks.
Our .htaccess file (we have .jsz files with compressed javascript, and Chrome handles them fine):
I answered a similar question with a much more conservative matching rule for when to Gzip:
See the original post: How can I make my .htaccess file allow Safari & other browsers to open GZIP?
You would just need to set the
Content-Encoding
header field to tell the client, that the response data is encoded with gzip:But unfortunatly Apache doesn’t allow to set that header field. Instead
Content-Encoding
will becomeX-Content-Encoding
.Content-Encoding: gzip
response header.Accept-Encoding
header allows GZIP.Download Fiddler and look at the raw response headers to see what the server is sending back for that particular request.
FYI, Fiddler is a client side proxy that filters your browser requests through. Super informative when dealing with these kind of issues.
-- Update
Upon further investigation, it doesn't appear that your RewriteCond is actually doing what you think it is doing. According to the Documentation, the RewriteCond directive is only used in conjunction with a RewriteRule.
Google Chrome (and Apple Safari) do not support gzip compressed CSS and JavaScript. Certain IE6 versions also have problems. They do support gzip compressed HTML documents, but not CSS and JavaScript.