This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

only manipulate headers once we're sure this is a cachified resource

  • Loading branch information...
lloyd committed Feb 17, 2012
1 parent 878cc59 commit 4ee17c60a58a619017079a6dac8d046f03c1f818
Showing with 9 additions and 7 deletions.
  1. +9 −7 lib/connect-cachify.js
View
@@ -84,16 +84,18 @@ exports.setup = function (assets, options) {
}
}
if (exists === true) {
+ // only manipulate headers if we've determined this is a
+ // cachify controlled url
resp.setHeader('Cache-Control', 'public, max-age=31536000');
+ resp.on('header', function () {
+ // Relax other middleware... I got this one
+ ['ETag', 'Last-Modified'].forEach(function (header) {
+ if (resp.getHeader(header)) resp.removeHeader(header);
+ if (resp.getHeader(header)) resp.removeHeader(header);
+ });
+ });
req.url = true_path;
}
- resp.on('header', function () {
- // Relax other middleware... I got this one
- ['ETag', 'Last-Modified'].forEach(function (header) {
- if (resp.getHeader(header)) resp.removeHeader(header);
- if (resp.getHeader(header)) resp.removeHeader(header);
- });
- });
}
next();
};

0 comments on commit 4ee17c6

Please sign in to comment.