Allow caching up to a week

This commit is contained in:
Peter 'Pita' Martischka 2011-05-28 20:43:00 +01:00
parent 537fca9ca4
commit 4eccf72baa
2 changed files with 9 additions and 6 deletions

View file

@ -25,6 +25,8 @@ var path = require('path');
var minify = require('./minify');
var serverName = "Etherpad-Lite ( http://j.mp/ep-lite )";
//cache a week
exports.maxAge = 1000*60*60*24*7;
async.waterfall([
//initalize the database
@ -47,7 +49,7 @@ async.waterfall([
{
res.header("Server", serverName);
var filePath = path.normalize(__dirname + "/.." + req.url.split("?")[0]);
res.sendfile(filePath, { maxAge: 1000*60*60 });
res.sendfile(filePath, { maxAge: exports.maxAge });
});
//serve minified files
@ -72,7 +74,7 @@ async.waterfall([
{
res.header("Server", serverName);
var filePath = path.normalize(__dirname + "/../static/pad.html");
res.sendfile(filePath, { maxAge: 1000*60*60 });
res.sendfile(filePath, { maxAge: exports.maxAge });
});
//serve index.html under /
@ -80,7 +82,7 @@ async.waterfall([
{
res.header("Server", serverName);
var filePath = path.normalize(__dirname + "/../static/index.html");
res.sendfile(filePath, { maxAge: 1000*60*60 });
res.sendfile(filePath, { maxAge: exports.maxAge });
});
//serve robots.txt
@ -88,7 +90,7 @@ async.waterfall([
{
res.header("Server", serverName);
var filePath = path.normalize(__dirname + "/../static/robots.txt");
res.sendfile(filePath, { maxAge: 1000*60*60 });
res.sendfile(filePath, { maxAge: exports.maxAge });
});
//serve favicon.ico
@ -96,7 +98,7 @@ async.waterfall([
{
res.header("Server", serverName);
var filePath = path.normalize(__dirname + "/../static/favicon.ico");
res.sendfile(filePath, { maxAge: 1000*60*60 });
res.sendfile(filePath, { maxAge: exports.maxAge });
});
//let the server listen