views:

59

answers:

1

I've tried to optimize my website using YSlow for directions. However, even though I have added the DEFLATE code at .htaccess to gzip the files, YSlow still doesn't show the files as gzipped. I tried testing my website using this: http://www.gidnetwork.com/tools/gzip-test.php and it shows that my webpages are not gzipped or compressed. How else can I make them gzipped or compressed?

This is the .htaccess:

SetOutputFilter DEFLATE
Header unset ETag
FileETag None

################ Expires Control ################
ExpiresActive On
ExpiresDefault A0
<FilesMatch "\.(gif|jpg|jpeg|png|swf)$">
# 2 weeks
ExpiresDefault A1209600
Header append Cache-Control "public"
</FilesMatch>
<FilesMatch "\.(xml|txt|html)$">
# 2 hours
ExpiresDefault A7200
Header append Cache-Control "proxy-revalidate"
</FilesMatch>
<FilesMatch "\.(js|css)$">
# 3 days
ExpiresDefault A259200
Header append Cache-Control "proxy-revalidate"
</FilesMatch>

Apart from this, what else can I do to optimize the speed and reduce the loading time of my webpage?

Also, the image on the page keeps loading every time I refresh the page. How do I cache it to make it load quickly?

+2  A: 

You could try to enable "mod_gzip"

Put this in your .htaccess

<ifModule mod_gzip.c>
  mod_gzip_on Yes
  mod_gzip_dechunk Yes
  mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
  mod_gzip_item_include mime ^text/.*
  mod_gzip_item_include mime ^application/x-javascript.*
  mod_gzip_item_exclude mime ^image/.*
  mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
Kwastie
I tried that, and yet it shows that my files are not gzipped. I'm not sure what else do I have to do to gzip them.
fuz3d
To be sure: are you sure you've changed the .htaccess rules I provided? (because these are just example rules)I think your web host might've disabled mod_gzip to safe some cpu cycles. ;-)
Kwastie
@Kwastie, how else then can I compress my files, if my webhost has disabled mod_gzip? Any other alternatives?
fuz3d
It's ugly but you can use the PHP "ob_gzhandler" (http://php.net/manual/en/function.ob-gzhandler.php) to compress all the requests. Little howto: http://www.ardamis.com/2010/07/11/compress-files-without-mod_gzip-or-mod_deflate/
Kwastie