add a CACHE_VERSION to invalid caches when versions become incompatible

This commit is contained in:
Randall Schmidt 2020-11-28 11:45:51 -05:00
parent 7e5c71ffe7
commit 6e782f49db

@ -6,6 +6,8 @@ const path = require('path');
const Response = require('./classes/response.js');
const CACHE_VERSION = 2;
function md5(str) {
return crypto.createHash('md5').update(str).digest('hex');
}
@ -63,7 +65,7 @@ function getCacheKey(requestArguments) {
resourceCacheKeyJson.body = getBodyCacheKeyJson(resourceCacheKeyJson.body);
initCacheKeyJson.body = getBodyCacheKeyJson(initCacheKeyJson.body);
return md5(JSON.stringify([resourceCacheKeyJson, initCacheKeyJson]));
return md5(JSON.stringify([resourceCacheKeyJson, initCacheKeyJson, CACHE_VERSION]));
}
async function createRawResponse(fetchRes) {