Forum Moderators: phranque

Message Too Old, No Replies

gzip cached while disabled

         

helenp

3:38 pm on Oct 2, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi, my shared host does not have gzip enabled,
so I read how to use gzip despite of that.

I have minified my 3 .js files (about 200 kbs), I have made them 1 file then I gzipped them with an online tool, so I now have a gzipped file with 36kb.
I renamed the .gz to .jgz (for safari).

I have this on top of my testpage:
<?php
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'))
ob_start("ob_gzhandler");
else
ob_start();
?>
in the html I have the .js as a link
and in the htaccess I have this:
RewriteEngine on
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}.jgz -f
RewriteRule (.*)\.js$ $1\.js.jgz [L]
AddType "text/javascript" .js.jgz
AddEncoding gzip .jgz
<FilesMatch "\.(gif|jpeg|jgz|gz|jpg|js|pdf|css|GIF|png|flv|swf|ico)$">
Header set Cache-Control: "max-age=1296000"
</FilesMatch>

I can see the jgz file is being cached using firebut/page speed, however when I click I can see the max cpu goes up, so I suppose the server have to unzip the .jgz file everytime.
I wonder if it is so and if there is a way to cache the unzipped file.
Thanks in advance

helenp

6:39 pm on Oct 2, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Also I read in php site that zlib is better than Ob_gzhandler.
I dont know how to use it or if its enabled a not, in a way it looks enabled and in another turned off.
This is from my phpinfo:
ZLib Support enabled
Stream Wrapper support compress.zlib://
Stream Filter support zlib.inflate, zlib.deflate
Compiled Version 1.2.3
Linked Version 1.2.3

DirectiveLocal ValueMaster Value
zlib.output_compressionOffOff
zlib.output_compression_level-1-1
zlib.output_handlerno valueno value