Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

only send 304 if original response in 2xx or 304

  • Loading branch information...
commit d90a2145db1653ff1c532071be0714b5b3a6c952 1 parent 74e7cdd
@timkuijsten authored
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/middleware/static.js
View
9 lib/middleware/static.js
@@ -181,9 +181,12 @@ var send = exports.send = function(req, res, next, options){
// conditional GET support
if (utils.conditionalGET(req)) {
- if (fresh(req.headers, res._headers)) {
- req.emit('static');
- return utils.notModified(res);
+ // only use cache if original response would have had a status code of 2xx or 304 (see RFC 2616 section 14.25 and 14.26)
+ if ((res.statusCode >= 200 && res.statusCode < 300) || res.statusCode === 304) {
+ if (fresh(req.headers, res._headers)) {
+ req.emit('static');
+ return utils.notModified(res);
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.