What requests do browsers' "F5" and "Ctrl + F5" refreshes generate?

HttpBrowserCachingCross BrowserRefresh

Http Problem Overview


Is there a standard for what actions F5 and Ctrl+F5 trigger in web browsers?

I once did experiment in IE6 and Firefox 2.x. The F5 refresh would trigger a HTTP request sent to the server with an If-Modified-Since header, while Ctrl+F5 would not have such a header. In my understanding, F5 will try to utilize cached content as much as possible, while Ctrl+F5 is intended to abandon all cached content and just retrieve all content from the servers again.

But today, I noticed that in some of the latest browsers (Chrome, IE8) it doesn't work in this way anymore. Both F5 and Ctrl+F5 send the If-Modified-Since header.

So how is this supposed to work, or (if there is no standard) how do the major browsers differ in how they implement these refresh features?

Http Solutions


Solution 1 - Http

It is up to the browser but they behave in similar ways.

F5 usually updates the page only if it is modified. Modern browsers sends Cache-Control: max-age=0 to tell any cache the maximum amount of time a resource is considered fresh, relative to the time of the request.

CTRL-F5 is used to force an update, disregarding any cache. Modern browsers sends Cache-Control: no-cache and Pragma: No-cache

If I remember correctly it was Netscape which was the first browser to add support for cache-control by adding Pragma: No-cache when you pressed CTRL-F5.

┌───────────┬──────────────┬─────┬─────────────────┬──────────────────────────────┐
│ Version 4F5RCLICKLegend:                      │
│2021 MAY 19├──┬──┬──┬──┬──┼──┬──┼──┬──┬──┬──┬──┬──┤ C = Cache-Control: no-cache  │
│           │  │SCAACC │  │SCAACI = If-Modified-Since        │
│           │  │HTLLTT │  │HTLLTM = Cache-Control: max-age=0 │
│           │  │IRTTRR │  │IRTTRN = Not tested               │
│           │  │FL │  │GLL │  │FL │  │GLP = Pragma: No-cache         │
│           │  │T │  │  │R │  │+ │  │T │  │  │R │+ │ - = ignored                  │
│           │  │  │  │  │  │  │S │  │  │  │  │  │S │                              │
│           │  │  │  │  │  │  │H │  │  │  │  │  │HWith 'CLICK' I refer to a    │
│           │  │  │  │  │  │  │I │  │  │  │  │  │Imouse click on the browsers  │
│           │  │  │  │  │  │  │F │  │  │  │  │  │Frefresh-icon.                │
│           │  │  │  │  │  │  │T │  │  │  │  │  │T │                              │
│           │  │  │  │  │  │  │  │  │  │  │  │  │  │ 1: Version 3.0.6 sends I     │
├───────────┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤    and C, but 3.1.6 opens    │
│Brave 1.24MCPCP--MCPMCPCPMCPCPthe page in a new tab,    │
├───────────┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤    making a normal request   │
│Chrome 1MIMIMI--MI-MIMIMIMIMINwith only I.              │
│Chrome 6MICPCP--MICPMICPCPMI-N2: Version 10.62 does        │
│Chrome 90MCPCP--MCPMCPCPMCPCPnothing. 9.61 might do C  │
├───────────┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤    unless it was a typo in   │
│Edge 90MCPCP--MCPMCPCPMCPCPmy old table.             │
├───────────┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤ 3: Opens the currernt tab in │
│Firefox 3.xMI-CP--MICPMICP1MMINa new tab, but does not   │
│Firefox 89M-CP-MMCPMCP3MM3refresh the page if it is │
├───────────┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤    cached in the browser.    │
│MSIE 8, 7I-C-II │  │IICIIN │                              │
├───────────┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤                              │
│Opera 10, 9C--2-C-CCCC-N │                              │
│Opera 76MCPCP--M-MCPCPMCPCP│                              │
├───────────┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──────────────────────────────┤
│                    https://stackoverflow.com/a/385491/36866                     │
└─────────────────────────────────────────────────────────────────────────────────┘

Note about Chrome 6.0.472: If you do a forced reload (like CTRL-F5) it behaves like the url is internally marked to always do a forced reload. The flag is cleared if you go to the address bar and press enter.

Solution 2 - Http

Generally speaking:

F5 may give you the same page even if the content is changed, because it may load the page from cache. But Ctrl+F5 forces a cache refresh, and will guarantee that if the content is changed, you will get the new content.

Solution 3 - Http

I've implemented cross-browser compatible page to test browser's refresh behavior (here is the source code) and get results similar to @some, but for modern browsers:

enter image description here

Solution 4 - Http

At least in Firefox (v3.5), cache seems to be disabled rather than simply cleared. If there are multiple instances of the same image on a page, it will be transferred multiple times. That is also the case for img tags that are added subsequently via Ajax/JavaScript.

So in case you're wondering why the browser keeps downloading the same little icon a few hundred times on your auto-refresh Ajax site, it's because you initially loaded the page using CTRL-F5.

Solution 5 - Http

IE7/8/9 seem to behave differently depending on whether the page has focus or not.

If you click on the page and CTRL+F5 then "Cache-Control: no-cache" is included in the request headers. If you click in the Location/Address bar then press CTRL+F5 it isn't.

Solution 6 - Http

When user press F5 although new request goes to web server and get a responce for the request as well. But when the responce header is Parsed it check the required information in browser cache. If the required information in cache has not expired then that information is restored from in cache itself.

When user click on CTRL-F5 even then new request goes to web server and get a responce. But this time when the responce header is Parsed it do not check any required information in cache, and bring all updated information form server only.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMorgan ChengView Question on Stackoverflow
Solution 1 - HttpsomeView Answer on Stackoverflow
Solution 2 - HttpdancavallaroView Answer on Stackoverflow
Solution 3 - HttpPavel PodlipenskyView Answer on Stackoverflow
Solution 4 - HttpmermshausView Answer on Stackoverflow
Solution 5 - HttpPhil HaseldenView Answer on Stackoverflow
Solution 6 - HttpSunilView Answer on Stackoverflow