ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Two Servlet Filters Every Web Application Should Have
Subject:   CPU Utilization ?
Date:   2004-01-09 07:46:45
From:   jfalkner
Response to: CPU Utilization ?

>re: CPU utilization
Yes, the compression requires more processing power. However, it normally isn't an issue, but if it is, you can deploy a cache filter to cache compressed content -- it is a simple modification of the cache filter given in this article.


>re: apply to 10k or less response size
Absolutely. The easiest way, using what exists, is to only deploy the filter on pages that are more than 10k or that are usually larger than 10k. This is as simple as mapping the filter to specific resources such as /index.jsp and /foo/bar.jsp instead of *.jsp.


Another more sophisticated method of doing this is to edit the filter's code. Currently the filter attempts to buffer/compress content. You could certainly check the buffer to see if it is less than 10k and optionally not compress it.


However, it is real important to make sure you care about the CPU time. If your server isn't taxed, why bother. Or if your server is taxed, why not set up a cache filter for the compressed content?