From 498002ee2dad7516c44c59e5fd1e4e5511886c0d Mon Sep 17 00:00:00 2001 From: Bobby Wibowo Date: Wed, 25 Apr 2018 14:30:38 +0700 Subject: [PATCH] Updated lolisafe.js Removed file extension check from setHeaders function. It will now apply Cache-Control to all files in /public, and to all files in the uploads folder if they are being served by node. --- lolisafe.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lolisafe.js b/lolisafe.js index 5b22c5c..5fdde3c 100644 --- a/lolisafe.js +++ b/lolisafe.js @@ -37,11 +37,10 @@ safe.use('/api/register/', limiter) safe.use(bodyParser.urlencoded({ extended: true })) safe.use(bodyParser.json()) -const setHeaders = (res, path, stat) => { - if (/\.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso|js|css|eot|svg|ttf|woff|woff2)$/.test(path)) { - res.set('Access-Control-Allow-Origin', '*') - res.set('Cache-Control', 'public, max-age=2592000, must-revalidate, proxy-revalidate, immutable, stale-while-revalidate=86400, stale-if-error=604800') // max-age: 30 days - } +const setHeaders = res => { + // Apply Cache-Control to all static files + res.set('Access-Control-Allow-Origin', '*') + res.set('Cache-Control', 'public, max-age=2592000, must-revalidate, proxy-revalidate, immutable, stale-while-revalidate=86400, stale-if-error=604800') // max-age: 30 days } if (config.serveFilesWithNode) {