The process of browser cache
- The browser fetch the content in
http://www.patrickcai.comfor the first time
- The server return the content with the two kinds of headers
Firstly ,the header should tell the browser when to fetch the content from the server instead of getting it from the web cache
Expires: Fri, 05 Jul 2002, 05:00:00 GMT
The max age is counted as seconds ,so only after 484200 seconds should the browser fetch the content from the server .
Secondly,when the browser cache expires, the client send the request with corresponding header which tell the server to compare the content in cache and server.There are two methods,comparing
etags are like the version number for the document,once the document is updated, the egags will also be updated.
Last-modified: "Wed, 07 Jan 2015 13:01:26 GMT"
- Next time, when the browser again trys to fetch the content in the same url.There are two situtations
- The cache has not expired yet, the client get the content from the browser cache
- The cache has expired, the client send the request with headers
If-Modified-Since:<date>the data comes from
If-None-Match: <tags>tags come from the
- The server compares the
etags,if the document has not been updated, the server will send the
304 Not modifiedstatus code and empty body entity.