Cache
The response can be cached at the client side. In response header, Cache-Control controls the cache.
- max-age: the available duration
- no-store: the reponse can't be cached
- no-cache: before using cache, ask server to check if it can be used.
- must-revalidate: After expiring, ask server to check if it can be used in the future.
When the cache is used
When we click backward.
If we refresh the web, the browser will send the request with Cache-Control: max-age=0. (Ctrl + F5 will add Cache-Control: no-cache.)
Use the cache
-
if-Modified-SinceandLast-modifiedThe previous response will set
Last-modified, a timestamp. The current request will put it inif-Modified-Since. If there is no update, the server will return a 304 Not Modified response. -
If-None-MatchandETagThe previous response will set
ETag, a unique resource identifier. The current request will put it inIf-None-Match. If there is matched, the server will return a 304 Not Modified response.