Browser Refresh cache mechanism

Source: Internet
Author: User
Tags nginx server

The cache can be visually understood as a copy.

Static caching : a static page that generates content as soon as new content is published.

Dynamic Cache : After the new content is published, the corresponding static page is not pre-generated, until the corresponding content requests, if the foreground cache server can not find the corresponding cache, the background Content Management Server to make a request, the background system will generate a static page of the corresponding content. The first time a user accesses a page, it may be a bit slower, but the cache is accessed directly later. (The dynamic cache is more advantageous than the static cache)


One: The Address bar Press Enter is also divided into two cases.

1. The requested URI does not expire in the browser cache, at which point the HTTP request message header displayed in the browser using the Firefox Firebug plugin is as follows:

Host 192.168.3.174:8080
User-agent mozilla/5.0 (Windows NT 5.1; rv:5.0) gecko/20100101 firefox/5.0
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-language zh-cn,zh;q=0.5
Accept-encoding gzip, deflate
Accept-charset gb2312,utf-8;q=0.7,*;q=0.7
Connection keep-alive

The HTTP return status displays a $ OK, but the access.log of the Nginx server did not find a record of the request, stating that the request was not actually committed to the HTTP server. Instead, the browser found that the cache has not expired files, directly intercepted the request, firebug inside the so-called "request header Message", "Response header message" is the browser "forged". This refresh, the use of network traffic is minimal, can be said to be completely no, time consumption is also the least. Just like you find a box of milk without expiration, feel sure there is no problem, no one told the drink.

2. The URI of the request is expired in the browser cache, at which point the HTTP request message header displayed by Firebug is as follows:

Host 192.168.3.174:8080
User-agent mozilla/5.0 (Windows NT 5.1; rv:5.0) gecko/20100101 firefox/5.0
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-language zh-cn,zh;q=0.5
Accept-encoding gzip, deflate
Accept-charset gb2312,utf-8;q=0.7,*;q=0.7
Connection keep-alive
If-modified-since Mon, Jul 10:12:40 GMT

More a row if-modified-since, the background nginx server Access.log also found the record of the request, that the browser to deal with this situation is: Ask the server again, the URI of the request has been modified after some time, This time is determined by the last-modified of the last HTTP response. After the server authentication, no modification, return 304 not Modified, after the browser received, read the content from the cache, if there is a change, return to OK, and return the new content. In this case, just like you find a box of milk that has expired, so ask others, can not drink, if others say yes, you drink it, if others say no, then you have to find another box of fresh milk.

Second, (F5 inside the browser: means to get the page cache that has not expired???. Whether the cache is out of date) asF5 Refresh, its HTTP request message header is as follows:

Host 192.168.3.174:8080
User-agent mozilla/5.0 (Windows NT 5.1; rv:5.0) gecko/20100101 firefox/5.0
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-language zh-cn,zh;q=0.5
Accept-encoding gzip, deflate
Accept-charset gb2312,utf-8;q=0.7,*;q=0.7
Connection keep-alive
If-modified-since Mon, Jul 10:12:40 GMT
Cache-control max-age=0

Another line of cache-control:max-age=0, meaning, I don't care if the file in the browser cache is not expired, go to the server to ask, the equivalent of the last HTTP response expires temporarily invalidated. The server's response process is the same as above. This situation, like you find a box of milk, do not see its expiration date, directly ask others can not drink.

ThreeCtrl+f5 Refresh, its HTTP request message header is as follows:

Host 192.168.3.174:8080
User-agent mozilla/5.0 (Windows NT 5.1; rv:5.0) gecko/20100101 firefox/5.0
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-language zh-cn,zh;q=0.5
Accept-encoding gzip, deflate
Accept-charset gb2312,utf-8;q=0.7,*;q=0.7
Connection keep-alive
Pragma No-cache
Cache-control No-cache

If-modified-since No, Cache-control replaced No-cache, in addition pragma line is to compatible HTTP1.0, the role and Cache-control:no-cache is the same. This means that I do not cache the files, forced to refresh, directly to the server to re-download, so the server response processing and the first request of the URI, the same as the return of the new content. This refresh, the use of network traffic is the largest, but also the most time-consuming. It's like you found a box of milk, but threw it away and went straight to buy a new box.

Partially transferred from http://www.cnblogs.com/mofish/archive/2012/06/08/2541604.html

Browser Refresh cache mechanism

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.