Allow caching up to a week

pull/35/head
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

@ -7,6 +7,7 @@ var pro = require("uglify-js").uglify;
var path = require('path');
var Buffer = require('buffer').Buffer;
var gzip = require('gzip');
var server = require('./server');
/**
* Answers a http request for the pad javascript
@ -201,7 +202,7 @@ exports.padJS = function(req, res)
pathStr = path.normalize(__dirname + "/../var/minified_pad.js");
}
res.sendfile(pathStr);
res.sendfile(pathStr, { maxAge: server.maxAge });
})
}
//minifying is disabled, so load the files with jquery

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