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

599,519

Solution 1

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 2

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.

Solution 3

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

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

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.

Share:
599,519
Morgan Cheng
Author by

Morgan Cheng

I am a software engineer in China. This is my Blog ??????????,??????

Updated on July 17, 2021

Comments

  • Morgan Cheng
    Morgan Cheng almost 3 years

    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?

  • Joel Coehoorn
    Joel Coehoorn about 15 years
    Any chance you could add SHIFT-ClickRefreshButton to this table?
  • Joel Coehoorn
    Joel Coehoorn about 15 years
    BTW: Very nice job color-coding the key like that.
  • some
    some about 15 years
    @Joel Coehoorn: Updated the table with click on the refresh button. Got to love ASCII graphic tables, don't you? The color-coding was is just a side-effect of the code color-coding.
  • John Topley
    John Topley about 15 years
    Can't you do it as a proper HTML table?
  • Kip
    Kip over 14 years
    FYI - this answer has actually been referenced on the chrome development/bug tracking boards: code.google.com/p/chromium/issues/detail?id=1906
  • some
    some over 13 years
    @Kyle: Thanks for correcting my spelling. @Kip: Thank you very much for the information about the chrome bug tracking. That made my day!
  • some
    some over 13 years
    @John Topley: Tables isn't allowed, so the answer is no.
  • cburgmer
    cburgmer almost 13 years
    Great work on this table - this belongs on quirksmode. +1. I wonder if there's also variation in what headers are used to request resources within the refreshed page, such as images, stylesheets, etc...
  • some
    some almost 13 years
    @James Hart: Thank you! This is the result I got after testing with a html document with an external script, css and image: For FF (4.0.1@win32) and MSIE(8.0.6001.18702@win32) it's the same type of request. Chrome (11.0.696.68@win32) also does the same, but if you force a reload (CTRL-F5) it behaves like an internal flag is set and if you press F5 again the HTML-document is retrieved with MP and all other with IM. Se the note above in the answer. Opera (11.01 1190@win32) does C for the HTML-document and I for the included resources.
  • Paul Irish
    Paul Irish almost 13 years
    I believe Chrome has updated its shift-refresh behavior as of 11 or 12 or so. Could we can get an update? Thanks!
  • some
    some almost 13 years
    @Paul Irish: I will check if they have changed it in a few days. BTW you noticed the note about chrome 6?
  • Ruan Mendes
    Ruan Mendes almost 12 years
    The links on your page are broken, I fixed the link on the answer, but a lot of the links from that page are broken. podlipensky.com/examples/refreshbutton/index.html , podlipensky.com/post/2012/02/27/…
  • Pavel Podlipensky
    Pavel Podlipensky almost 12 years
    Sorry, about that - doing blog migration. Links will be fixed ASAP, for now - please go to github repository and download examples.
  • AaronLS
    AaronLS over 11 years
    Thi is accurate, but note that while Ctrl+F5 will cause the browser to throw out the cache and request a new from the server, the server may ignore the no-cache header and serve a server side cached page. Thus even Ctrl+F5 may return an old version of the page if the server ignores the no-cache header.
  • bernardn
    bernardn over 9 years
    The links are still broken. Migration not finished?
  • Dimitri Dewaele
    Dimitri Dewaele over 9 years
    F5 wil refresh the page - CTRL+F5 will do 'hard' refresh.
  • jawo
    jawo over 8 years
    Also mention, that Ctrl-F5 will submit a form, if given.
  • Greg Dubicki
    Greg Dubicki over 8 years
    Can you please update your answer with current version of the browsers, especially mobile and desktop Safari, @PavelPodlipensky?
  • molerus
    molerus over 7 years
    Ok, so if you hit ctrl+f5 you tell your browser not to use its cache, but what happens in subsequent requests to the same page? I mean, can you see older versions of the page after you´ve seen the oldest one? If i´m seeing version 1 of the page because its cached but theres already version 2 available, i understand that hitting ctrl+f5 will make me see version2. Then i close my browser and open that page again, ¿do i see version 1 or i still see version2? Thanks.
  • some
    some about 3 years
    @PaulIrish 10 years later, the table is updated. :)