ETag/caching fixes and improvements
This commit is contained in:
parent
d993c805fe
commit
3c29cb0f65
2 changed files with 5 additions and 13 deletions
|
@ -1,7 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var crypto = require('crypto'),
|
var fs = require('fs'),
|
||||||
fs = require('fs'),
|
|
||||||
path = require('path');
|
path = require('path');
|
||||||
|
|
||||||
var clone = require('clone'),
|
var clone = require('clone'),
|
||||||
|
@ -59,12 +58,11 @@ module.exports = function(options, repo, params, id) {
|
||||||
return res.status(500).send(err.message);
|
return res.status(500).send(err.message);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var md5 = crypto.createHash('md5').update(data).digest('base64');
|
|
||||||
headers['content-md5'] = md5;
|
|
||||||
if (tileJSON['format'] == 'pbf') {
|
if (tileJSON['format'] == 'pbf') {
|
||||||
headers['content-type'] = 'application/x-protobuf';
|
headers['Content-Type'] = 'application/x-protobuf';
|
||||||
headers['content-encoding'] = 'gzip';
|
headers['Content-Encoding'] = 'gzip';
|
||||||
}
|
}
|
||||||
|
delete headers['ETag']; // do not trust the tile ETag -- regenerate
|
||||||
res.set(headers);
|
res.set(headers);
|
||||||
|
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
var async = require('async'),
|
var async = require('async'),
|
||||||
advancedPool = require('advanced-pool'),
|
advancedPool = require('advanced-pool'),
|
||||||
crypto = require('crypto'),
|
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
util = require('util'),
|
util = require('util'),
|
||||||
|
@ -78,9 +77,6 @@ module.exports = function(options, repo, params, id) {
|
||||||
if (headers['Last-Modified']) {
|
if (headers['Last-Modified']) {
|
||||||
response.modified = new Date(headers['Last-Modified']);
|
response.modified = new Date(headers['Last-Modified']);
|
||||||
}
|
}
|
||||||
if (headers['ETag']) {
|
|
||||||
response.etag = headers['ETag'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (format == 'pbf') {
|
if (format == 'pbf') {
|
||||||
response.data = zlib.unzipSync(data);
|
response.data = zlib.unzipSync(data);
|
||||||
|
@ -292,10 +288,8 @@ module.exports = function(options, repo, params, id) {
|
||||||
return res.status(404).send('Not found');
|
return res.status(404).send('Not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
var md5 = crypto.createHash('md5').update(buffer).digest('base64');
|
|
||||||
res.set({
|
res.set({
|
||||||
'content-md5': md5,
|
'Content-Type': 'image/' + format
|
||||||
'content-type': 'image/' + format
|
|
||||||
});
|
});
|
||||||
return res.status(200).send(buffer);
|
return res.status(200).send(buffer);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue