Gzip, css, js

Hi,

I am having an issue, or so I believe, with GZIP working for JavScript and CSS. Everything else appears to be working OK except for files ending in .js or .css.

I have run some tests using various webtools and GZIP is running and also is running according to the HTTP HEADERS.

The problem is, when I run the Page Speed test from Google, it tells me I need to use GZIP on some .js and .css files.

I’ve tried so many different things in my .htaccess file but nothing seems to work. I must be missing something.

Does anyone have some suggestions?

Thanks

Hi,

I assume you’re checking via Google Webmaster Tools? If so, it tends to take days for it to update the status in it’s page speed suggestions - took a week to detect when we turned Gzip on for JS.

Thanks,

For apache 1.0: http://www.samaxes.com/2008/04/htaccess-gzip-and-cache-your-site-for-faster-loading-and-bandwidth-saving/
For apache 2.0: http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/

You don’t need to provide compressed files…apache does the compression on-the-fly.

Although I am certainly still open for suggestions, I believe I have it figured out. I thought there would be an easier way but this seems to work.

I downloaded a free tool called 7-Zip to compress the CSS and JavaScript files and uploaded them to my server with an extension of .css.jgz or .js.jgz. Then I added the following to my .htaccess. It worked.

RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}.jgz -f
RewriteRule (.*)\.js$ $1\.js.jgz [L]
AddType “text/javascript” .js.jgz
AddEncoding gzip .jgz

RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}.jgz -f
RewriteRule (.*)\.css$ $1\.css.jgz [L]
AddType “text/css” .css.jgz
AddEncoding gzip .jgz

As stated, I am still open for suggestions if there are any.

Thanks much,