Browse Source

Merge pull request #322 from pelias/remove_cache_control_headers

remove cache control headers
pull/324/head
Peter Johnson a.k.a. insertcoffee 9 years ago
parent
commit
3629a49dc1
  1. 2
      middleware/404.js
  2. 2
      middleware/408.js
  3. 2
      middleware/500.js
  4. 2
      middleware/headers.js
  5. 2
      test/ciao/404.coffee
  6. 2
      test/ciao/index.coffee

2
middleware/404.js

@ -1,7 +1,7 @@
// handle not found errors
function middleware(req, res) {
res.header('Cache-Control','public,max-age=300'); // 5 minute cache
res.header('Cache-Control','public');
res.status(404).json({ error: 'not found: invalid path' });
}

2
middleware/408.js

@ -1,7 +1,7 @@
// handle time out errors
function middleware(err, req, res, next) {
res.header('Cache-Control','no-cache');
res.header('Cache-Control','public');
var error = (err && err.message) ? err.message : err;
if( res.statusCode === 408 || (error.toLowerCase().indexOf('request timeout') !== -1) ){

2
middleware/500.js

@ -3,7 +3,7 @@ var logger = require( 'pelias-logger' ).get( 'middleware-500' );
// handle application errors
function middleware(err, req, res, next) {
logger.error( 'Error: `%s`. Stack trace: `%s`.', err, err.stack );
res.header('Cache-Control','no-cache');
res.header('Cache-Control','public');
var error = (err && err.message) ? err.message : err;
if( res.statusCode < 400 ){ res.status(500); }

2
middleware/headers.js

@ -3,7 +3,7 @@ var pkg = require('../package');
function middleware(req, res, next){
res.header('Charset','utf8');
res.header('Cache-Control','public,max-age=60');
res.header('Cache-Control','public');
res.header('Server', 'Pelias/'+pkg.version);
res.header('X-Powered-By', 'mapzen');
next();

2
test/ciao/404.coffee

@ -9,7 +9,7 @@ response.statusCode.should.be.equal 404
response.should.have.header 'Content-Type','application/json; charset=utf-8'
#? cache-control header correctly set
response.should.have.header 'Cache-Control','public,max-age=300'
response.should.have.header 'Cache-Control','public'
#? should respond in json with server info
should.exist json

2
test/ciao/index.coffee

@ -12,7 +12,7 @@ response.should.have.header 'Content-Type','text/html; charset=utf-8'
response.should.have.header 'Charset','utf8'
#? cache-control header correctly set
response.should.have.header 'Cache-Control','public,max-age=60'
response.should.have.header 'Cache-Control','public'
#? server header correctly set
response.should.have.header 'Server'

Loading…
Cancel
Save