Skip to content

Commit

Permalink
Merge pull request #2 from jhoff/master
Browse files Browse the repository at this point in the history
maxAge option, 1 day expire default
  • Loading branch information
Nick Crohn committed Dec 1, 2011
2 parents 8b5f968 + c756503 commit dc4da1c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ module.exports = function(options) {
var uglify = require("uglify-js"),
fsys = require("../lib/filesystem.js"),
url = require("url"),
src;
src,
maxAge = options.maxAge || 86400000; // default to 1 day

if(options.hasOwnProperty("src")) {
src = options.src;
Expand Down Expand Up @@ -57,6 +58,8 @@ module.exports = function(options) {

} else {
console.log('"GET', path, '" 200 - Cached');
res.setHeader('Expires', new Date(Date.now() + maxAge).toUTCString());
res.setHeader('Cache-Control', 'public, max-age=' + (maxAge / 1000));
res.contentType("js");
res.send(data, 200);
}
Expand Down

0 comments on commit dc4da1c

Please sign in to comment.