react-cache-buster
react-cache-buster copied to clipboard
Assumption "XHR requests are not kept in the cache" not always true
Looks like the assumption "XHR requests are not kept in the cache" on which react-cache-buster is based it's not always true. Maybe adding a timestamp can do the trick.
const res = await fetch(`${getMetaFileDirectory()}/meta.json?${Date.now()}`);
Hello, is this going to be addressed? I am also having similar issues.
I manually applied the fix suggested by @balbo to this file and it fixed everything: node_modules\react-cache-buster\dist\index.js:69
/meta.json?${Date.now()}
try {
var _temp2 = _catch(function () {
return Promise.resolve(fetch(getMetaFileDirectory() + `/meta.json?${Date.now()}`)).then(function (res) {
return Promise.resolve(res.json()).then(function (_ref2) {
var metaVersion = _ref2.version;
var shouldForceRefresh = isThereNewVersion(metaVersion, currentVersion);
...
I have fixed it by using the following in entry file for app
if (typeof window !== 'undefined') {
const { fetch: originalFetch } = window
window.fetch = async (...args) => {
const [resource, ...rest] = args
let modifiedResource = resource
if (resource === '/meta.json') {
modifiedResource = `/meta.json?v=${Date.now()}`
}
const response = await originalFetch(modifiedResource, ...rest)
return response
}
}
Is someone still maintaining this library?
Maybe the problem is that it is the GET request which might be cached, so changing it to the POST request will solve the problem?