From a11f5c1378110c8b8b912c5e6a91f6503062e1e9 Mon Sep 17 00:00:00 2001 From: webzwo0i Date: Fri, 20 Nov 2020 21:15:33 +0100 Subject: [PATCH] make code easier to understand --- src/node/utils/caching_middleware.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/node/utils/caching_middleware.js b/src/node/utils/caching_middleware.js index 366085c4b..beea15bff 100644 --- a/src/node/utils/caching_middleware.js +++ b/src/node/utils/caching_middleware.js @@ -20,7 +20,6 @@ var fs = require('fs'); var path = require('path'); var zlib = require('zlib'); var settings = require('./Settings'); -var semver = require('semver'); var existsSync = require('./path_exists'); /* @@ -192,16 +191,14 @@ CachingMiddleware.prototype = new function () { res.write = old_res.write || res.write; res.end = old_res.end || res.end; - var headers = responseCache[cacheKey].headers; + let headers = {}; + Object.assign(headers, (responseCache[cacheKey].headers || {})); var statusCode = responseCache[cacheKey].statusCode; var pathStr = CACHE_DIR + 'minified_' + cacheKey; if (supportsGzip && /^application\/javascript/.test(headers['content-type'])) { pathStr = pathStr + '.gz'; headers['content-encoding'] = 'gzip'; - } else { - // ensure responseCache is updated - delete headers['content-encoding']; } var lastModified = (headers['last-modified']