Skip to content

Prevent caching of json data #178

@systemsplanet-zz

Description

@systemsplanet-zz

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} );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions