Permalink
Browse files

Add If-Modified-Since header support.

  • Loading branch information...
1 parent 64c34d9 commit 574f897ec0046bddda916bb718894cab13cfe2a2 @cliffano cliffano committed Apr 6, 2012
Showing with 8 additions and 2 deletions.
  1. +8 −2 lib/assetmanager.js
View
@@ -396,8 +396,14 @@ module.exports = function assetManager (assets) {
headers['Content-Encoding'] = response.encoding
}
- res.writeHead(200, headers);
- res.end(response.contentBuffer);
+ if (req.headers['if-modified-since'] &&
+ Date.parse(req.headers['if-modified-since']) >= Date.parse(response.modified)) {
+ res.writeHead(304, headers);
+ res.end();
+ } else {
+ res.writeHead(200, headers);
+ res.end(response.contentBuffer);
+ }
}
return;
}

0 comments on commit 574f897

Please sign in to comment.