HTTP 1.1 Caching (ETag / If-None-Match)
Posted: Sun Sep 11, 2005 9:09 am
I notice that CMSMS sends content pages and stylesheets in full on every request, even for HTTP 1.1 clients. Can't we avoid this to save bandwidth?
1. Client makes first GET request for a particular URL.
2. Server sends extra HTTP header with the content: an MD5 hash of the HTTP response body...
ETag: 0xedfc43ac
3. Next client request for the same URL will include HTTP header...
If-None-Match: 0xedfc43ac
4. After generating the dynamic content as normal, the server compares the new ETag MD5 hash with the client's If-None-Match MD5 hash.
If the two MD5 hashes match, then just send...
304 Not Modified
Never tried this, but I think it's intended to solve the problem you often have with dynamic content, that you need to work out whether the data has changed since this client last requested it, but not at the expense of more file or database I/O.
Any thoughts?
1. Client makes first GET request for a particular URL.
2. Server sends extra HTTP header with the content: an MD5 hash of the HTTP response body...
ETag: 0xedfc43ac
3. Next client request for the same URL will include HTTP header...
If-None-Match: 0xedfc43ac
4. After generating the dynamic content as normal, the server compares the new ETag MD5 hash with the client's If-None-Match MD5 hash.
If the two MD5 hashes match, then just send...
304 Not Modified
Never tried this, but I think it's intended to solve the problem you often have with dynamic content, that you need to work out whether the data has changed since this client last requested it, but not at the expense of more file or database I/O.
Any thoughts?