From 946568d3a3d2d012f155246901d834cf86d222c4 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Thu, 30 Jun 2011 12:40:37 +0100 Subject: [PATCH] Revert "Remove caching, creates more problems than it solves" This reverts commit a4b9427896e565dff3c26e916991f7ae169e6beb. --- node/minify.js | 2 +- node/server.js | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/node/minify.js b/node/minify.js index bc1612aa..7245b214 100644 --- a/node/minify.js +++ b/node/minify.js @@ -225,7 +225,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 diff --git a/node/server.js b/node/server.js index 108f7a67..72b76120 100644 --- a/node/server.js +++ b/node/server.js @@ -32,6 +32,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*1; async.waterfall([ //initalize the database @@ -54,7 +56,7 @@ async.waterfall([ { res.header("Server", serverName); var filePath = path.normalize(__dirname + "/.." + req.url.split("?")[0]); - res.sendfile(filePath); + res.sendfile(filePath, { maxAge: exports.maxAge }); }); //serve minified files @@ -86,7 +88,7 @@ async.waterfall([ res.header("Server", serverName); var filePath = path.normalize(__dirname + "/../static/pad.html"); - res.sendfile(filePath); + res.sendfile(filePath, { maxAge: exports.maxAge }); }); //serve timeslider.html under /p/$padname/timeslider @@ -101,7 +103,7 @@ async.waterfall([ res.header("Server", serverName); var filePath = path.normalize(__dirname + "/../static/timeslider.html"); - res.sendfile(filePath); + res.sendfile(filePath, { maxAge: exports.maxAge }); }); //serve index.html under / @@ -109,7 +111,7 @@ async.waterfall([ { res.header("Server", serverName); var filePath = path.normalize(__dirname + "/../static/index.html"); - res.sendfile(filePath); + res.sendfile(filePath, { maxAge: exports.maxAge }); }); //serve robots.txt @@ -117,7 +119,7 @@ async.waterfall([ { res.header("Server", serverName); var filePath = path.normalize(__dirname + "/../static/robots.txt"); - res.sendfile(filePath); + res.sendfile(filePath, { maxAge: exports.maxAge }); }); //serve favicon.ico @@ -125,7 +127,7 @@ async.waterfall([ { res.header("Server", serverName); var filePath = path.normalize(__dirname + "/../static/favicon.ico"); - res.sendfile(filePath); + res.sendfile(filePath, { maxAge: exports.maxAge }); }); //let the server listen