Search code examples
cross-browserhttp-headershttprequestbrowser-cacheprefetch

Http <link type="prefetch" vs. pragma: no-cache


What will happen if a html page has a prefetch link to a resource that has a no-cache pragma header?


Solution

  • but if it loads a resource without actually using it will it be discarded on subsequent request?

    This is browser dependent. IE11 operates as follows:

    Prerendered pages are not always displayed to the user. These conditions cause prerendered pages to be discarded from memory without being displayed:

    The user doesn't open the target page within five minutes.
    The user opens a different page.
    The user switches to a different tab or browser instance.
    A JavaScript process adds a new link element that requests a different webpage to prerender.
    An error occurs while loading the target page, including HTTP error code 500 (server error), 404 (resource not found), or related errors (such as connection problems).
    

    When a prerendered page is discarded and then requested later, it's loaded from the hosting server directly. If the page is still in browser cache, it might load more quickly; however, this is not guaranteed.

    References