diff --git a/NEWS.md b/NEWS.md index 1ba26de3..0654bfc4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ 1.5.2 ----- * Keep numbers as such in JSON output (#100) +* Revert max-age=0 in Cache-Control when using no-cache 1.5.1 ----- diff --git a/app/controllers/app.js b/app/controllers/app.js index 3222ed39..63bbfa97 100755 --- a/app/controllers/app.js +++ b/app/controllers/app.js @@ -262,13 +262,10 @@ function handleQuery(req, res) { if ( cache_policy == 'persist' ) { res.header('Cache-Control', 'public,max-age=31536000'); // 1 year } else { - // don't cache the result ! - // NOTE: both Varnish and Cloudfront ignore this header, - // X-Cache-Channel is for controlling Varnish - // Cloudfront can only be skipped perturbating the URL - // + // TODO: set ttl=0 when tableCache[sql_md5].may_write is true ? + var ttl = 3600; res.header('Last-Modified', new Date().toUTCString()); - res.header('Cache-Control', 'no-cache,max-age=0,must-revalidate,public'); + res.header('Cache-Control', 'no-cache,max-age='+ttl+',must-revalidate,public'); } return result; diff --git a/test/acceptance/app.test.js b/test/acceptance/app.test.js index d080e5b8..8ffcb1e8 100644 --- a/test/acceptance/app.test.js +++ b/test/acceptance/app.test.js @@ -30,7 +30,7 @@ app.setMaxListeners(0); suite('app.test', function() { -var expected_cache_control = 'no-cache,max-age=0,must-revalidate,public'; +var expected_cache_control = 'no-cache,max-age=3600,must-revalidate,public'; var expected_cache_control_persist = 'public,max-age=31536000'; test('GET /api/v1/sql', function(done){