By Morgan Cheng


2008-12-22 02:00:08 8 Comments

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 comments

@Pavel Podlipensky 2012-03-12 16:59:02

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

@Juan Mendes 2012-06-19 23:25:11

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 2012-06-20 23:21:29

Sorry, about that - doing blog migration. Links will be fixed ASAP, for now - please go to github repository and download examples.

@bernardn 2015-01-29 11:25:31

The links are still broken. Migration not finished?

@Greg Dubicki 2015-08-20 15:07:09

Can you please update your answer with current version of the browsers, especially mobile and desktop Safari, @PavelPodlipensky?

@some 2008-12-22 03:40:59

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

I have tested FF, IE7, Opera and Chrome.

F5 usually updates the page only if it is modified. The browser usually tries to use all types of cache as much as possible and adds an "If-modified-since" header to the request. Opera differs by sending a "Cache-Control: no-cache".

CTRL-F5 is used to force an update, disregarding any cache. IE7 adds an "Cache-Control: no-cache", as does FF, which also adds "Pragma: no-cache". Chrome does a normal "If-modified-since" and Opera ignores the key.

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.

Edit: Updated table

The table below is updated with information on what will happen when the browser's refresh-button is clicked (after a request by Joel Coehoorn), and the "max-age=0" Cache-control-header.

Updated table, 27 September 2010

┌────────────┬───────────────────────────────────────────────┐
│  UPDATED   │                Firefox 3.x                    │
│27 SEP 2010 │  ┌────────────────────────────────────────────┤
│            │  │             MSIE 8, 7                      │
│ Version 3  │  │  ┌─────────────────────────────────────────┤
│            │  │  │          Chrome 6.0                     │
│            │  │  │  ┌──────────────────────────────────────┤
│            │  │  │  │       Chrome 1.0                     │
│            │  │  │  │  ┌───────────────────────────────────┤
│            │  │  │  │  │    Opera 10, 9                    │
│            │  │  │  │  │  ┌────────────────────────────────┤
│            │  │  │  │  │  │                                │
├────────────┼──┼──┼──┼──┼──┼────────────────────────────────┤
│          F5│IM│I │IM│IM│C │                                │
│    SHIFT-F5│- │- │CP│IM│- │ Legend:                        │
│     CTRL-F5│CP│C │CP│IM│- │ I = "If-Modified-Since"        │
│      ALT-F5│- │- │- │- │*2│ P = "Pragma: No-cache"         │
│    ALTGR-F5│- │I │- │- │- │ C = "Cache-Control: no-cache"  │
├────────────┼──┼──┼──┼──┼──┤ M = "Cache-Control: max-age=0" │
│      CTRL-R│IM│I │IM│IM│C │ - = ignored                    │
│CTRL-SHIFT-R│CP│- │CP│- │- │                                │
├────────────┼──┼──┼──┼──┼──┤                                │
│       Click│IM│I │IM│IM│C │ With 'click' I refer to a      │
│ Shift-Click│CP│I │CP│IM│C │ mouse click on the browsers    │
│  Ctrl-Click│*1│C │CP│IM│C │ refresh-icon.                  │
│   Alt-Click│IM│I │IM│IM│C │                                │
│ AltGr-Click│IM│I │- │IM│- │                                │
└────────────┴──┴──┴──┴──┴──┴────────────────────────────────┘

Versions tested:

  • Firefox 3.1.6 and 3.0.6 (WINXP)
  • MSIE 8.0.6001 and 7.0.5730.11 (WINXP)
  • Chrome 6.0.472.63 and 1.0.151.48 (WINXP)
  • Opera 10.62 and 9.61 (WINXP)

Notes:

  1. Version 3.0.6 sends I and C, but 3.1.6 opens the page in a new tab, making a normal request with only "I".

  2. Version 10.62 does nothing. 9.61 might do C unless it was a typo in my old table.

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.

@Joel Coehoorn 2009-02-20 15:37:37

Any chance you could add SHIFT-ClickRefreshButton to this table?

@Joel Coehoorn 2009-02-20 15:38:38

BTW: Very nice job color-coding the key like that.

@some 2009-02-20 18:11:52

@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 2009-02-20 18:32:28

Can't you do it as a proper HTML table?

@Kip 2010-01-29 19:28:47

FYI - this answer has actually been referenced on the chrome development/bug tracking boards: code.google.com/p/chromium/issues/detail?id=1906

@some 2010-09-24 14:50:04

@Kyle: Thanks for correcting my spelling. @Kip: Thank you very much for the information about the chrome bug tracking. That made my day!

@some 2010-10-03 23:41:02

@John Topley: Tables isn't allowed, so the answer is no.

@James Hart 2011-05-20 14:54:24

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 2011-05-20 18:53:53

@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 ([email protected]) and MSIE([email protected]) it's the same type of request. Chrome ([email protected]) 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 [email protected]) does C for the HTML-document and I for the included resources.

@Paul Irish 2011-08-04 19:01:14

I believe Chrome has updated its shift-refresh behavior as of 11 or 12 or so. Could we can get an update? Thanks!

@some 2011-08-05 15:57:09

@Paul Irish: I will check if they have changed it in a few days. BTW you noticed the note about chrome 6?

@Sunil 2009-03-06 07:26:53

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.

@Phil Haselden 2011-10-12 00:31:44

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.

@mermshaus 2009-07-22 08:47:31

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.

@dancavallaro 2008-12-22 02:10:55

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.

@AaronLS 2012-08-23 20:47:31

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.

@Dimitri Dewaele 2015-02-05 13:16:58

F5 wil refresh the page - CTRL+F5 will do 'hard' refresh.

@Sempie 2015-08-20 10:53:22

Also mention, that Ctrl-F5 will submit a form, if given.

@molerus 2017-01-18 07:50:22

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.

Related Questions

Sponsored Content

73 Answered Questions

[SOLVED] How do you disable browser Autocomplete on web form field / input tag?

18 Answered Questions

[SOLVED] Get the size of the screen, current web page and browser window

31 Answered Questions

[SOLVED] What is the difference between a URI, a URL and a URN?

  • 2008-10-06 21:26:58
  • Sean McMains
  • 1118334 View
  • 4262 Score
  • 31 Answer
  • Tags:   http url uri urn rfc3986

17 Answered Questions

[SOLVED] What is the maximum length of a URL in different browsers?

  • 2009-01-06 16:14:30
  • Sander Versluys
  • 1206949 View
  • 4729 Score
  • 17 Answer
  • Tags:   http url browser

11 Answered Questions

27 Answered Questions

[SOLVED] How can I refresh a page with jQuery?

20 Answered Questions

[SOLVED] HTTP GET with request body

  • 2009-06-10 20:47:24
  • Evert
  • 1016420 View
  • 1955 Score
  • 20 Answer
  • Tags:   rest http http-get

38 Answered Questions

[SOLVED] How to align checkboxes and their labels consistently cross-browsers

26 Answered Questions

[SOLVED] How do we control web page caching, across all browsers?

32 Answered Questions

[SOLVED] What exactly is RESTful programming?

  • 2009-03-22 14:45:39
  • hasen
  • 1641910 View
  • 3939 Score
  • 32 Answer
  • Tags:   http rest definition

Sponsored Content