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

后端 未结 6 958
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 09:00

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

相关标签:
6条回答
  • 2020-11-22 09:19

    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

    0 讨论(0)
  • 2020-11-22 09:25

    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.

    0 讨论(0)
  • 2020-11-22 09:30

    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.

    0 讨论(0)
  • 2020-11-22 09:36

    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.

    0 讨论(0)
  • 2020-11-22 09:45

    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.

    0 讨论(0)
  • 2020-11-22 09:45

    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.

    0 讨论(0)
提交回复
热议问题