Tidbits | Jan. 2, 2006

Using Apache's mod_deflate for speed

by Frank Wiles |   More posts by Frank

If you have a site that sends large textual content ( XHTML, XML, CSS, plain text, etc. ) to a browser via Apache you should investigate using mod_deflate. This Apache module compresses your content at the server, before sending to the browser. This can dramatically speed up the time it takes for your pages to load. Especially for users on slower Internet connections. Many Linux distributions already have mod_deflate installed, but if yours does not you will need to install it by hand.

For example, an application I wrote called NewsCloud has some pages that are over 350K of XHTML. This can take awhile even on the fastest of home Internet connections. But by having mod_deflate compress the content before sending it to the browser 350K of XHTML becomes a much more managable 40K. Obviously your results will vary based upon your content. Because NewsCloud is a mod_perl application this is what I added to my config:

         <Location /newscloud>   
   SetOutputFilter DEFLATE  
   ExpiresByType text/html "access plus 2 hours"  

The ExpiresByType instructs the browser to keep cached any content from this particular Location for 2 hours after it was last accessed. This also is useful to ensure a user's experience is good, but obviously varies depending on the nature of the application you are building. It wouldn't be too smart in a shopping cart for instance... " Hey?!?!?! Where the $@#$# did my stuff go?"

Tp learn more about mod_deflate you should check out this article, "Apache 2 mod_deflate Benchmark"

open source  

2006-01-02T08:29:34 2018-04-18T15:59:18.680260 2006 open source