What is the difference between a carriage return (enter) and a refresh in the browser? Reproduced

Source: Internet
Author: User
Tags browser cache nginx server

What's the difference between a carriage return and a F5 refresh in the browser? Today, say: What is the difference between a carriage return (enter) in a browser and a refresh? This matter.

Introduction:

1, enter in the expires effective time, is not to request the server, open debugging see the request is also only forged, such as Google Browser may display (cached) (more than the normal 200) actually did not initiate the actual cache, directly read the local hard disk cache.

2. If F5 is pressed, the expires setting is no longer effective, only last-modified/etag has effect, if 304 is returned within the cache period, then the local cache content is read

3, Ctrl+f5 will send Cache-control:no-cache, the real re-fetch files from the server, when the cache is completely invalid

First, "Refresh", it is on the basis of your existing page, check whether the page has updated content. While checking, the values of some of the previous variables are retained, so it is possible to make the page error after the refresh, or not open the situation, "go" and the Address bar return, the equivalent of you re-enter the page URL access, in which case, the browser will try to use the cache already exists in the native. That is, "refresh" is to fetch the new content of the Web page to update the native cache, while keeping some of the previous variables while updating, "Go" is a new access, it will try to use the files in the native cache, but will not retain the previous variables, this should be understood? In addition, press CTRL, can also be forced to refresh, with the same effect.

Many students ask, is not all refreshing it? What difference does it have? In fact, there are still some.

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 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

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. This situation,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.

What is the difference between a carriage return (enter) and a refresh in the browser? Reproduced

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.