Permalink
Browse files

Merge pull request #34 from cliffano/master

Fix response headers
  • Loading branch information...
2 parents e83df42 + 574f897 commit 5c0eeb9c6a14fca3d8d811d64d6f38b694624c82 @mape committed Apr 6, 2012
Showing with 11 additions and 4 deletions.
  1. +11 −4 lib/assetmanager.js
View
@@ -387,16 +387,23 @@ module.exports = function assetManager (assets) {
'Content-Length': response.contentLength,
'Last-Modified': response.modified,
'Date': (new Date).toUTCString(),
- 'Cache-Control': 'public max-age=' + 31536000,
- 'Expires': response.expires || (new Date(new Date().getTime()+63113852000)).toUTCString()
+ 'Cache-Control': 'public,max-age=' + 31536000,
+ 'Expires': response.expires || (new Date(new Date().getTime()+63113852000)).toUTCString(),
+ 'Vary': 'Accept-Encoding'
};
if(response.encoding) {
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 5c0eeb9

Please sign in to comment.