From bf4c295e4802713c87ed7c0b068107c6d36d85a8 Mon Sep 17 00:00:00 2001 From: Randall Schmidt Date: Sat, 28 Nov 2020 11:45:51 -0500 Subject: [PATCH] add a CACHE_VERSION to invalid caches when versions become incompatible --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index f779c99..44dd531 100644 --- a/index.js +++ b/index.js @@ -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) {