Turbolinks: Difference between no-cache and (full page) reload?

Created on 26 Sep 2018  Â·  2Comments  Â·  Source: turbolinks/turbolinks

I'm trying to understand the difference between:

Do they perform the same thing (i.e. always fetch page from server)?

Thanks soooooo much for this aweseome lib!

Most helpful comment

Hi @asmith26

<meta name="turbolinks-visit-control" content="reload"> tells Turbolinks to perform a full page load. Upon visiting a page containing that meta tag, Turbolinks will call window.location.reload() to request a completely fresh page from the server. All assets will be reloaded and evaluated. This tends to be used when dealing with a third-party library which is incompatible with Turbolinks in some way (see https://github.com/turbolinks/turbolinks/issues/311 for the background on this).

The turbolinks-cache-control directive determines the caching behaviour. Setting this to no-cache on a given page means that the page will never be cached. Returning to the page by tapping Back/Forward, or by clicking a link, will result in Turbolinks fetching the page via XHR, merging the <head> and replacing the <body>. Because of this, it is more efficient than a full page load (but not as quick as rendering a cached copy). It is useful if you have a particular page that changes frequently, and you want to be certain that it is up-to-date whenever visited.

Do they perform the same thing (i.e. always fetch page from server)?

They will both result in fetching and rendering pages from the server, yes, but turbolinks-visit-control … reload does a _full_ page reload, whereas turbolinks-cache-control … no-cache will render the page via JavaScript.

Hope that clarifies things.

All 2 comments

Hi @asmith26

<meta name="turbolinks-visit-control" content="reload"> tells Turbolinks to perform a full page load. Upon visiting a page containing that meta tag, Turbolinks will call window.location.reload() to request a completely fresh page from the server. All assets will be reloaded and evaluated. This tends to be used when dealing with a third-party library which is incompatible with Turbolinks in some way (see https://github.com/turbolinks/turbolinks/issues/311 for the background on this).

The turbolinks-cache-control directive determines the caching behaviour. Setting this to no-cache on a given page means that the page will never be cached. Returning to the page by tapping Back/Forward, or by clicking a link, will result in Turbolinks fetching the page via XHR, merging the <head> and replacing the <body>. Because of this, it is more efficient than a full page load (but not as quick as rendering a cached copy). It is useful if you have a particular page that changes frequently, and you want to be certain that it is up-to-date whenever visited.

Do they perform the same thing (i.e. always fetch page from server)?

They will both result in fetching and rendering pages from the server, yes, but turbolinks-visit-control … reload does a _full_ page reload, whereas turbolinks-cache-control … no-cache will render the page via JavaScript.

Hope that clarifies things.

Thank you very much for this clarification, all makes sense to me now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

coffeebite picture coffeebite  Â·  29Comments

nerdcave picture nerdcave  Â·  16Comments

kstratis picture kstratis  Â·  13Comments

ezekg picture ezekg  Â·  16Comments

gregblass picture gregblass  Â·  17Comments