Skip to content

Commit

Permalink
Added the proper response headers for the 304 path and removed the 'c…
Browse files Browse the repository at this point in the history
…hattiness' with the console.log code accidentally left in.
  • Loading branch information
David Ellis committed Jul 18, 2011
1 parent e717fa3 commit 621e73a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/staticGzip.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ exports = module.exports = function staticGzip(dirPath, options){
return pass(filename);
}

console.log(req.headers);
//This is storing in memory for the moment, need to think what the best way to do this.
//Check file is not a directory

Expand All @@ -141,6 +140,13 @@ exports = module.exports = function staticGzip(dirPath, options){
if (req.headers['if-modified-since'] &&
gzippoCache[gzipName] &&
(new Date(gzippoCache[gzipName].mtime)).getTime() >= (new Date(req.headers['if-modified-since'])).getTime()) {
contentType = contentType + (charset ? '; charset=' + charset : '');
res.setHeader('Content-Type', contentType);
res.setHeader('Content-Encoding', 'gzip');
res.setHeader('Vary', 'Accept-Encoding');
res.setHeader('Last-Modified', gzippoCache[gzipName].mtime);
res.setHeader('Date', (new Date()).toUTCString());
res.setHeader('Expires', (new Date((new Date()).getTime()+maxAge)).toUTCString());
return res.send(304);
}

Expand Down

0 comments on commit 621e73a

Please sign in to comment.