Skip to content

Commit

Permalink
Fixed staticCache() Age header field
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Oct 16, 2011
1 parent 4b2941e commit 53a19a9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/middleware/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ var send = exports.send = function(req, res, next, options){
// conditional GET support
if (utils.conditionalGET(req)) {
if (!utils.modified(req, res)) {
req.emit('static', null);
req.emit('static');
return utils.notModified(res);
}
}
Expand Down
5 changes: 2 additions & 3 deletions lib/middleware/staticCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = function staticCache(options){
if (!contentLength || contentLength > maxlen) return;

// dont cache items we shouldn't be
if (cc['no-cache']
if ( cc['no-cache']
|| cc['no-store']
|| cc['private']
|| cc['must-revalidate']) return;
Expand Down Expand Up @@ -108,9 +108,8 @@ module.exports = function staticCache(options){

// cache hit, doesnt support range requests
if (hit && hit.complete && !ranges) {
// todo clean these messy headers
header = utils.merge({}, hit[0]);
header.Age = age = (new Date - header.date) / 1000 | 0;
header.Age = age = (new Date - new Date(header.date)) / 1000 | 0;
header.date = new Date().toUTCString();

// parse cache-controls
Expand Down

0 comments on commit 53a19a9

Please sign in to comment.