Monday, April 20, 2009

HTTP Performance Tips - Add Expires or a Cache-Control Header

According to Yahoo HTTP best practices, adding an Expires or Cache-Control header helps to increase performance of web server. Ideally, the performance should increase as cached data are not request and transmitted over the next visit.

To archive that, you should
  1. For static components: implement "Never expire" policy by setting far future Expires header
  2. For dynamic components: use an appropriate Cache-Control header to help the browser with conditional requests. The value is 48 hours.
To archive this in tomcat, you have to create a Servlet Filter to intercept incoming request and set the above HTTP header in response.

I am not going to post code here as there are many existing code out there. But, if you have no idea on what to search for, those links below will help

  1. I had tested this Expires Serlvet and it works.
  2. HTTP 1.1 Protocol Parameter
  3. HTTP 1.1 Header Fields Definition

No comments:

Post a Comment

Tomcat - removing server info

Below are the steps to remove Tomcat Server Information 1. Make sure Tomcat is not running 2. Navigate to "Tomcat Installation"...