我在泛型函数中添加了一个条件,该条件发送所有请求,将本地存储项与使用的上一个版本以及头中返回的版本进行比较
如果版本不同,则调用json来查找要刷新的文件,然后向每个项目发送post请求,这样浏览器就会更新文件。
// generic fuction to consume REST API
$.ajax({type: 'POST', url: base + url, dataType: 'json', async: true, data: data}).done(function (response, status, xhr) {
// the version returned by the REST API
let frontVersion = xhr.getResponseHeader('Front-Version');
if (localStorage.getItem('LS_FRONT_VERSION') !== frontVersion) {
// update the version the local storage
localStorage.setItem('LS_FRONT_VERSION', frontVersion);
// show an alert to the user
ui.alert('Reloading page...');
// function to reload files from a given array
let refresh=(items)=>{
//
let item = items.pop();
console.log('Reloading: ', item);