Set max-age=0 when using no-cache (don't be self-contraddicting)
This commit is contained in:
parent
7eff0cb107
commit
46e93355c4
1
NEWS.md
1
NEWS.md
@ -4,6 +4,7 @@
|
||||
* Add --skipfields switch to cdbsql
|
||||
* Fix windowing with CTE
|
||||
* Retain UTC offset in JSON date output
|
||||
* Set max-age=0 in Cache-Control when using no-cache
|
||||
|
||||
1.4.0
|
||||
-----
|
||||
|
@ -262,10 +262,13 @@ function handleQuery(req, res) {
|
||||
if ( cache_policy == 'persist' ) {
|
||||
res.header('Cache-Control', 'public,max-age=31536000'); // 1 year
|
||||
} else {
|
||||
// TODO: set ttl=0 when tableCache[sql_md5].may_write is true ?
|
||||
var ttl = 3600;
|
||||
// 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
|
||||
//
|
||||
res.header('Last-Modified', new Date().toUTCString());
|
||||
res.header('Cache-Control', 'no-cache,max-age='+ttl+',must-revalidate,public');
|
||||
res.header('Cache-Control', 'no-cache,max-age=0,must-revalidate,public');
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -30,7 +30,7 @@ app.setMaxListeners(0);
|
||||
|
||||
suite('app.test', function() {
|
||||
|
||||
var expected_cache_control = 'no-cache,max-age=3600,must-revalidate,public';
|
||||
var expected_cache_control = 'no-cache,max-age=0,must-revalidate,public';
|
||||
var expected_cache_control_persist = 'public,max-age=31536000';
|
||||
|
||||
test('GET /api/v1/sql', function(done){
|
||||
|
Loading…
Reference in New Issue
Block a user