Add `Last-Modified' headers to improve caching

This commit is contained in:
Petr Sloup 2016-07-26 10:24:53 +08:00
parent d465142275
commit dbaca66b2c
2 changed files with 6 additions and 0 deletions

View file

@ -11,6 +11,8 @@ var clone = require('clone'),
module.exports = function(options, allowedFonts) {
var app = express().disable('x-powered-by');
var lastModified = new Date().toUTCString();
var fontPath = options.paths.fonts;
var getFontPbf = function(name, range, callback) {
@ -51,6 +53,7 @@ module.exports = function(options, allowedFonts) {
return res.status(400).send('');
} else {
res.header('Content-type', 'application/x-protobuf');
res.header('Last-Modified', lastModified);
return res.send(concated);
}
});

View file

@ -38,6 +38,8 @@ mbgl.on('message', function(e) {
module.exports = function(options, repo, params, id) {
var app = express().disable('x-powered-by');
var lastModified = new Date().toUTCString();
var rootPath = options.paths.root;
var styleFile = params.style;
@ -289,6 +291,7 @@ module.exports = function(options, repo, params, id) {
}
res.set({
'Last-Modified': lastModified,
'Content-Type': 'image/' + format
});
return res.status(200).send(buffer);