diff --git a/server.js b/server.js index d758616..aa35794 100644 --- a/server.js +++ b/server.js @@ -46,11 +46,14 @@ var app = express(); app.use(express.static(__dirname + '/images')); +var cacheTimeout = 60 * 60 * 24 * 30; + app.get('/', function(req, res) { var width = 400; var seed = uuid(); var canvas = composeImage(width, width, seed); var buffer = canvas.toBuffer(); + res.set('Cache-Control', 'max-age=' + cacheTimeout); res.set('Content-length', buffer.length); res.type('png'); res.end(buffer, 'binary'); @@ -65,6 +68,7 @@ app.get('/:width', function(req, res) { var seed = uuid(); var canvas = composeImage(width, width, seed); var buffer = canvas.toBuffer(); + res.set('Cache-Control', 'max-age=' + cacheTimeout); res.set('Content-length', buffer.length); res.type('png'); res.end(buffer, 'binary'); @@ -75,6 +79,7 @@ app.get('/:width/:seed', function(req, res) { var seed = sanitize(req.params.seed) || uuid(); var canvas = composeImage(width, width, seed); var buffer = canvas.toBuffer(); + res.set('Cache-Control', 'max-age=' + cacheTimeout); res.set('Content-length', buffer.length); res.type('png'); res.end(buffer, 'binary');