From 8c40df3a7fbeffd1c5ed185a838c19d84a228b2e Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Sun, 1 Feb 2015 13:31:58 -0600 Subject: [PATCH] Cache fixing --- app.js | 5 ++++- etc/config/gcc-explorer.amazon.properties | 1 + etc/config/gcc-explorer.defaults.properties | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index ec20fe0f..a178498a 100755 --- a/app.js +++ b/app.js @@ -49,6 +49,7 @@ var rootDir = opts.rootDir || './etc'; props.initialize(rootDir + '/config', propHierarchy); var port = props.get('gcc-explorer', 'port', 10240); +var staticMaxAgeMs = props.get('gcc-explorer', 'staticMaxAgeMs', 0); function loadSources() { var sourcesDir = "lib/sources"; @@ -95,6 +96,7 @@ function getSource(req, res, next) { return; } action.apply(handler, bits.slice(3).concat(function (err, response) { + res.set('Cache-Control', 'public, max-age=' + staticMaxAgeMs); if (err) { res.end(JSON.stringify({err: err})); } else { @@ -161,6 +163,7 @@ function clientOptionsHandler(compilers, fileSources) { var text = "var OPTIONS = " + JSON.stringify(options) + ";"; return function getClientOptions(req, res) { res.set('Content-Type', 'application/javascript'); + res.set('Cache-Control', 'public, max-age=' + staticMaxAgeMs); res.end(text); }; } @@ -212,7 +215,7 @@ findCompilers().then(function (compilers) { webServer .use(logger('combined')) .use(sFavicon('static/favicon.ico')) - .use(sStatic('static')) + .use(sStatic('static', {maxAge: staticMaxAgeMs})) .use(bodyParser.urlencoded({extended: true})) .get('/client-options.js', clientOptionsHandler(compilers, fileSources)) .use('/source', getSource) diff --git a/etc/config/gcc-explorer.amazon.properties b/etc/config/gcc-explorer.amazon.properties index 40a0516f..05a13bcf 100644 --- a/etc/config/gcc-explorer.amazon.properties +++ b/etc/config/gcc-explorer.amazon.properties @@ -2,6 +2,7 @@ compileTimeoutMs=2000 compiler-wrapper=./c-preload/compiler-wrapper max-asm-size=500000 +staticMaxAgeMs=600000 cacheMb=300 clientGoogleAnalyticsEnabled=true compilers=g447:g453:g464:g473:g481:g490:armg453:clang30:avrg453:armg463:icc1301:clang32:clang33:clang341:g490c1:g490c2 diff --git a/etc/config/gcc-explorer.defaults.properties b/etc/config/gcc-explorer.defaults.properties index 8a351697..ab8ffdf4 100644 --- a/etc/config/gcc-explorer.defaults.properties +++ b/etc/config/gcc-explorer.defaults.properties @@ -10,3 +10,4 @@ cacheMb=200 language=C++ options=-O2 maxConcurrentCompiles=2 +staticMaxAgeMs=1000