How can I say "current age" of a cached page?

I am wondering how the browser determines if a cached resource has run out or not.

Suppose I set the header max-ageto 300. I made a request at 14:00, after 3 minutes I made another request for the same resource. So, how can the browser say that the resource has not expired (a value current agethat is 180 less than max-age)? Does the browser save an “expiration date” or “current age” for each requested resource? If so, how can I check the “current age” at the time I made the request?

0
source share
2 answers

Check which browsers are cached

To better understand how the browser cache works, check what browsers store in the cache:

  • Firefox: Go to about:cache.
  • Chrome: Go to chrome://cache.

Note that there is a key for each cache entry (requested URL). Associated with the key, you will find all the details of the response (status codes, headers and content). With these details, the browser can determine the age of the requested resource and whether it expires or not.

HTTP Caching Link

RFC 7234 , the current link for caching in HTTP / 1.1, will tell you a good part of the story about how the cache should work:

2. Overview of the cache operation

HTTP       . -   HTTP, ,    ,    . [...]

HTTP-   , , .       : 200 (OK) GET,    ,   .    , (, 404 ( )),    (, 206 ( ))   , GET,    - -.

URI.   , HTTP , ,    GET,    URI . [...]

:

3.

, :

  •  cacheable

  • ,

  • no-store  

  • private   ,

  • Authorization  , ,   ,

  • :

    • Expires

    • max-age

    • s-maxage ,

    • Cache Control Extension, ,

    • , ,

    • public.

, . [...]

+2

( ) , , Date, , . Date . Date , , , . Last-Modified.

, , Date . , , , Date . HTTP .

, !

+1

Source: https://habr.com/ru/post/1654058/


All Articles