add a CACHE_VERSION to invalid caches when versions become incompatible
This commit is contained in:
parent
7e5c71ffe7
commit
6e782f49db
4
index.js
4
index.js
@ -6,6 +6,8 @@ const path = require('path');
|
|||||||
|
|
||||||
const Response = require('./classes/response.js');
|
const Response = require('./classes/response.js');
|
||||||
|
|
||||||
|
const CACHE_VERSION = 2;
|
||||||
|
|
||||||
function md5(str) {
|
function md5(str) {
|
||||||
return crypto.createHash('md5').update(str).digest('hex');
|
return crypto.createHash('md5').update(str).digest('hex');
|
||||||
}
|
}
|
||||||
@ -63,7 +65,7 @@ function getCacheKey(requestArguments) {
|
|||||||
resourceCacheKeyJson.body = getBodyCacheKeyJson(resourceCacheKeyJson.body);
|
resourceCacheKeyJson.body = getBodyCacheKeyJson(resourceCacheKeyJson.body);
|
||||||
initCacheKeyJson.body = getBodyCacheKeyJson(initCacheKeyJson.body);
|
initCacheKeyJson.body = getBodyCacheKeyJson(initCacheKeyJson.body);
|
||||||
|
|
||||||
return md5(JSON.stringify([resourceCacheKeyJson, initCacheKeyJson]));
|
return md5(JSON.stringify([resourceCacheKeyJson, initCacheKeyJson, CACHE_VERSION]));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createRawResponse(fetchRes) {
|
async function createRawResponse(fetchRes) {
|
||||||
|
Reference in New Issue
Block a user