In the browser address bar press ENTER, F5, ctrl+f5 refresh the page difference--Go

Source: Internet
Author: User
Tags one more line browser cache nginx server

where you press Enter in the address bar is divided into two cases. One is that the requested URI does not expire in the browser cache, at this 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.

The second is that the requested URI has 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

One more line of If-modified-since, The access.log of the background Nginx server also found the record of the request, indicating that the browser is handling this situation: Ask the server again, the requested URI has not been modified after a certain time, and 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.

As for 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
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.

Finally, Ctrl+f5 refreshes with the HTTP request message header 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.

Original address: http://blog.csdn.net/yui/article/details/6584401

Related Article

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.