Switches cacheKey from base64 of path to sha256 of path; fixes #3502

pull/3797/head
Tom Hudson 2020-03-30 17:08:47 +01:00 committed by muxator
parent 6c12a7fb1f
commit fc754c9a1d
1 changed files with 2 additions and 1 deletions

View File

@ -22,6 +22,7 @@ var zlib = require('zlib');
var settings = require('./Settings');
var semver = require('semver');
var existsSync = require('./path_exists');
var crypto = require('crypto');
var CACHE_DIR = path.normalize(path.join(settings.root, 'var/'));
CACHE_DIR = existsSync(CACHE_DIR) ? CACHE_DIR : undefined;
@ -49,7 +50,7 @@ CachingMiddleware.prototype = new function () {
(req.get('Accept-Encoding') || '').indexOf('gzip') != -1;
var path = require('url').parse(req.url).path;
var cacheKey = Buffer.from(path).toString('base64').replace(/[/+=]/g, '');
var cacheKey = crypto.createHash('sha256').update(path).digest('hex');
fs.stat(CACHE_DIR + 'minified_' + cacheKey, function (error, stats) {
var modifiedSince = (req.headers['if-modified-since']