You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browsers cache the json returned from a html links
Ideally, Exhibit is using the latest json data.
We can prevent caching by appending a random number: <link href="senators.json?i=232323.232323" type="application/json" rel="exhibit-data" />
We can generate this HTML dynamically
// create an HTML head link with optional cache buster
function loadExhibitResource(file, opts ){
if (opts && opts.cache && opts.cache === 'no') file += "?i="+(Math.random()*99999999);
var link = document.createElement("link");
link.href = file;
link.type = 'application/json';
link.rel = 'exhibit-data';
document.getElementsByTagName("head")[0].appendChild(link);
}
loadExhibitResource('senators.json', {cache: no} );
The text was updated successfully, but these errors were encountered:
This would be great to have but not always---for static exhibits it's going to force lots of wasted fetches. So ideally this would be something you could turn on or off, perhaps by putting a parameter into the link tag e.g. data-ex-cache=false or data-ex-no-cache=true . A pull request would be welcome!
Thank you for the trick.
By the way, you need to add quotes to cahe value when calling the method: loadExhibitResource('senators.json', {cache: 'no'} );
Browsers cache the json returned from a html links
Ideally, Exhibit is using the latest json data.
We can prevent caching by appending a random number:
<link href="senators.json?i=232323.232323" type="application/json" rel="exhibit-data" />
We can generate this HTML dynamically
The text was updated successfully, but these errors were encountered: