HTTP Caching: Difference between revisions

Jump to navigation Jump to search
Line 12: Line 12:
If it is easy to generate a unique identifier that always changes when the response changes you can use that as an ETag identifier. This is done using the [[ETag Header]]:
If it is easy to generate a unique identifier that always changes when the response changes you can use that as an ETag identifier. This is done using the [[ETag Header]]:


  ETag: W/"my-unique-identifier"
ETag: W/"my-unique-identifier"
  Cache-Control: public,maxage=5,must-revalidate
Cache-Control: public,maxage=5,must-revalidate


This example will ask the cache to keep serving this response to requests coming in in the next 5 seconds. If a matching request comes in after the five seconds the cache will check whether it still has the last version using the [[If-None-Match header]].
This example will ask the cache to keep serving this response to requests coming in in the next 5 seconds. If a matching request comes in after the five seconds the cache will check whether it still has the last version using the [[If-None-Match header]].

Navigation menu