[Pkg-javascript-commits] [node-static] 20/151: only serve from cache if it's recent enough

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Tue Jan 7 23:17:56 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch master
in repository node-static.

commit 9ce5781911c50038f60c29ed7495176849acae06
Author: cloudhead <self at cloudhead.net>
Date:   Tue Aug 3 19:28:53 2010 -0400

    only serve from cache if it's recent enough
---
 lib/node-static.js | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/node-static.js b/lib/node-static.js
index 79898a0..41208e8 100644
--- a/lib/node-static.js
+++ b/lib/node-static.js
@@ -182,7 +182,10 @@ this.Server.prototype.respond = function (pathname, files, stat, req, res, finis
 
         res.writeHead(200, headers);
 
-        if (this.cache && (key in exports.store)) {
+        // If the file was cached and it's not older
+        // than what's on disk, serve the cached version.
+        if (this.cache && (key in exports.store) &&
+            exports.store[key].stat.mtime >= stat.mtime) {
             res.end(exports.store[key].buffer);
             finish(200, {});
         } else {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-static.git



More information about the Pkg-javascript-commits mailing list