Skip to content

Commit

Permalink
Allow clientMaxAge to be set to 0
Browse files Browse the repository at this point in the history
Fixes tomgco#22
  • Loading branch information
awwx committed Jan 23, 2013
1 parent aa0b6cd commit 1e4b955
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/staticGzip.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@ exports = module.exports = function staticGzip(dirPath, options){
var
maxAge = options.maxAge || 86400000,
contentTypeMatch = options.contentTypeMatch || /text|javascript|json/,
clientMaxAge = options.clientMaxAge || 604800000,
clientMaxAge = options.clientMaxAge,
prefix = options.prefix || '';

if (typeof clientMaxAge === "undefined" || clientMaxAge === null)
clientMaxAge = 604800000;

if (!dirPath) throw new Error('You need to provide the directory to your static content.');
if (!contentTypeMatch.test) throw new Error('contentTypeMatch: must be a regular expression.');

Expand Down
10 changes: 10 additions & 0 deletions test/staticGzipTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ module.exports = {
}
);
},
'max age can be set to 0 to disable caching by the browser': function() {
assert.response(staticProvider.createServer(gzippo.staticGzip(fixturesPath, {clientMaxAge: 0})),
{
url: '/tomg.co.png'
},
function(res) {
assert.includes(res.headers['cache-control'], 'max-age=0');
}
);
},
'Normal traversal should work': function() {
assert.response(getApp(),
{
Expand Down

0 comments on commit 1e4b955

Please sign in to comment.