406
votes

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?

6
FWIW: while this certainly could be a Super User topic, and may even have been intended as somewhat end-user-focused when originally asked, at this point it has been both answered and referenced by programmers and web developers and should probably be left here. SU has several other, more end-user-oriented versions of this already, and doesn't need it...Shog9
I may be crazy but I think ALT+F5 does the same as CTRL+F5.ashleedawg
@ashleedawg According to my research (see table in my answer) only Opera 9 does something with ALT+F5 but not CTRL+F5, while all other tested browsers does something with CTRL+F5 but not ALT+F5. This is on Windows. What OS and browser was you using?some

6 Answers

330
votes

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.

528
votes

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 4 │      F5      │  R  │      CLICK      │ Legend:                      │
│2021 MAY 19├──┬──┬──┬──┬──┼──┬──┼──┬──┬──┬──┬──┬──┤ C = Cache-Control: no-cache  │
│           │  │S │C │A │A │C │C │  │S │C │A │A │C │ I = If-Modified-Since        │
│           │  │H │T │L │L │T │T │  │H │T │L │L │T │ M = Cache-Control: max-age=0 │
│           │  │I │R │T │T │R │R │  │I │R │T │T │R │ N = Not tested               │
│           │  │F │L │  │G │L │L │  │F │L │  │G │L │ P = Pragma: No-cache         │
│           │  │T │  │  │R │  │+ │  │T │  │  │R │+ │ - = ignored                  │
│           │  │  │  │  │  │  │S │  │  │  │  │  │S │                              │
│           │  │  │  │  │  │  │H │  │  │  │  │  │H │ With 'CLICK' I refer to a    │
│           │  │  │  │  │  │  │I │  │  │  │  │  │I │ mouse click on the browsers  │
│           │  │  │  │  │  │  │F │  │  │  │  │  │F │ refresh-icon.                │
│           │  │  │  │  │  │  │T │  │  │  │  │  │T │                              │
│           │  │  │  │  │  │  │  │  │  │  │  │  │  │ 1: Version 3.0.6 sends I     │
├───────────┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤    and C, but 3.1.6 opens    │
│Brave 1.24 │M │CP│CP│- │- │M │CP│M │CP│CP│M │CP│CP│    the page in a new tab,    │
├───────────┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤    making a normal request   │
│Chrome 1   │MI│MI│MI│- │- │MI│- │MI│MI│MI│MI│MI│N │    with only I.              │
│Chrome 6   │MI│CP│CP│- │- │MI│CP│MI│CP│CP│MI│- │N │ 2: Version 10.62 does        │
│Chrome 90  │M │CP│CP│- │- │M │CP│M │CP│CP│M │CP│CP│    nothing. 9.61 might do C  │
├───────────┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤    unless it was a typo in   │
│Edge 90    │M │CP│CP│- │- │M │CP│M │CP│CP│M │CP│CP│    my old table.             │
├───────────┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤ 3: Opens the currernt tab in │
│Firefox 3.x│MI│- │CP│- │- │MI│CP│MI│CP│1 │M │MI│N │    a new tab, but does not   │
│Firefox 89 │M │- │CP│- │M │M │CP│M │CP│3 │M │M │3 │    refresh the page if it is │
├───────────┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤    cached in the browser.    │
│MSIE 8, 7  │I │- │C │- │I │I │  │I │I │C │I │I │N │                              │
├───────────┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤                              │
│Opera 10, 9│C │- │- │2 │- │C │- │C │C │C │C │- │N │                              │
│Opera 76   │M │CP│CP│- │- │M │- │M │CP│CP│M │CP│CP│                              │
├───────────┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──────────────────────────────┤
│                    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.

69
votes

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

10
votes

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.

4
votes

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.

2
votes

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.