Wednesday, August 27, 2008 3:46 AM
kolbis
Boosting Your Web Application Performance: ETag
There are several ways to cache HTTP responses and ETag is one of them. ETag is a nice feature that can sometimes help boosting the performance for a web application. Basically the idea behind ETag is to prevent redownloading and processing a page that has not been modified.
The origin server specifies the ETag using the response header:
HTTP/1.1 200 OK
Last-Modified: Tue, 12 Dec 2006 03:03:59 GMT
ETag: "10c24bc-4ab-457e1c1f"
Content-Length: 12195
The browser will check for the expiration:
GET /i/yahoo.gif HTTP/1.1
Host: us.yimg.com
If-Modified-Since: Tue, 12 Dec 2006 03:03:59 GMT
If-None-Match: "10c24bc-4ab-457e1c1f"
HTTP/1.1 304 Not Modified
Wikipedia, describes it very well:
"An ETag (entity tag) is an HTTP response header returned by an HTTP/1.1 compliant web server used to determine change in content at a given URL. When a new HTTP response contains the same ETag as an older HTTP response, the contents are determined to be the same without further downloading. The header is useful for intermediary devices that perform caching, as well as client web browsers that cache results. One method of generating the ETag is based on the last modified time of the file and the size of the file."
However, one thing to note is that when using a load balancer or a web farm, the ETag does not really works! The reason for this is the fact that the ETag generates a "key" to identify the expiration for the response that is unique to a specific machine! Thus when given a "key" from one machine is will be invalid in the second machine and the response will not be supplied from the cache...
תגים:Performance, Dev