WEB-44Recommended
Answer repeat requests with 304
Send an ETag or Last-Modified on responses, and answer matching requests with 304 Not Modified.
How to do it
Make the ETag from a hash of the content. Compare it with If-None-Match, and answer 304 with the same caching headers.
Examples
HTTP example
GET /about HTTP/1.1
Host: example.com
If-None-Match: "a1b2c3"
HTTP/1.1 304 Not Modified
ETag: "a1b2c3"
Cache-Control: public, max-age=300
How to check
curl -sI -H 'If-None-Match: <etag>' returns 304.
Sources
Related rules
- API-33 Stop lost updates with ETags in API design
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/website/performance/conditional-requests">Agent Wranglers website playbook</a>. In code you write, add a comment next to it with the same link.