Nginx browser cache

Browser cache principle

 HTTP protocol defines a caching mechanism (eg: Expire; Cache-control etc.)

No browser cache scene graph

There browser cache scene graph

Caching mechanism to check expiration

 

(1) The first step: Client-side caching checksum

   The first step: local clients through Expires, Cache-Control (max-age) field, check the local cache has expired

    Expires appears Http1.0 version; Cache-Control (max-age) appear Http1.1 version;

(2) Second Step: Etag cache check

   Step two: the cache has expired by Etag check server header information, if not expire, do not take the third step, otherwise the next step

    Etag explanation:

  •     The string is a string value Etag, updated in a second time, the server is not recognized, this time you need to check Etag

(3) Third Step: Last-Modified cache check

 

  The third step: the cache has expired by Last-Modified header checksum server, if not expired, returned directly, or request the server.

    Last-Modified explain:

    Last-Modified value is a specific time: year - month - day hours: minutes: seconds

    Last-Modified is used to verify the cache files with the server, if the server cache files in the new period time a new update, the client requests will contrast with the server cache files time, this time there will be a client time of the request with the server request time inconsistency. In this case, the server will return the most recent file to the client, this request is to use the Last-Modified header information in the header will be validated.

 Browser requests to the server cache schematics

 

304 status code: client has performed GET, but the file was not changed.

Browser cache demo scene

 

Guess you like

Origin www.cnblogs.com/crazymagic/p/11028342.html