I'm trying to understand the difference between:
<meta name="turbolinks-cache-control" content="no-cache">, and<meta name="turbolinks-visit-control" content="reload">Do they perform the same thing (i.e. always fetch page from server)?
Thanks soooooo much for this aweseome lib!
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.
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 callwindow.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-controldirective determines the caching behaviour. Setting this tono-cacheon 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.They will both result in fetching and rendering pages from the server, yes, but
turbolinks-visit-control … reloaddoes a _full_ page reload, whereasturbolinks-cache-control … no-cachewill render the page via JavaScript.Hope that clarifies things.