You can speed-up your pages by installing mod_deflate – this module simply compresses data when send to the client. Text files can be compressed to levels of 15-30% of their original size, so depending on the type of data you can get even more than 200% speed-up when loading your pages.

You need to have turn on mod_deflate.

Then you need to set directory for which DEFLATE filetr will be applied. You do something like this:

<Directory "/path/to/your/dir">
  #AddOutputFilterByType DEFLATE text/html text/plain text/xml
  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

  # Don’t compress images
  SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

  # Make sure proxies don’t deliver the wrong content
  Header append Vary User-Agent env=!dont-vary
</Directory>

You might also turn on logging of what was deflated and how much it was compressed. You set it in your conf as follows:

<VirtualHost X.X.X.X:80>
  ...

  # Lets see what is being deflated
  DeflateFilterNote ratio

  LogFormat '"%r" %b (%{ratio}n) "%{User-agent}i"' deflate
  CustomLog /home/users/userXX/www.somedomain.com/log/deflate_log deflate

  ...
</VirtualHost>


As a result you get something like this:

"GET /info.html HTTP/1.1" 5589 (17)
"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1"

This line says that file “/info.html” was served – its original size is 5589 bytes and it was compressed by 17%. So the file really transfered was about 950 bytes.

Another log entry from deflate_log is the following:

"GET /skin/frontend/default/default/images/success_msg_icon.gif HTTP/1.1" 1024 (-)
"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1"

This line says that the size of “/skin/frontend/default/default/images/success_msg_icon.gif” is 1024 and it was not compressed. It does not make sense to compress gif or other already compressed formats. There is no benefit to do that – only waste of processor resources.

Resources

  1. Apache Module mod_deflate.
    http://httpd.apache.org/docs/2.0/mod/mod_deflate.html
  2. Improve the Speed of Your Magento Site.
    http://www.blastedthing.com/magento/site-speed/mag-improve-the-speed-of-your-magento-site/
  3. Best Practices for Speeding Up Your Web Site.
    http://developer.yahoo.com/performance/rules.html#gzip
mod_deflate
Tagged on:

Leave a Reply