Skip to content

Commit

Permalink
Adding client max age directives
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgco committed Jul 20, 2011
1 parent fb1f4d9 commit d370626
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Options:

- `matchType` - A regular expression tested against the Content-Type header to determine whether the response should be gzipped or not. The default value is `/text|javascript|json/`.
- `maxAge` - cache-control max-age directive, defaulting to 1 day
- `clientMaxAge` - browser cache-control max-age directive, defaulting to 1 week

Currently the gzipped version is created and stored in memory. This is not final and was done to get a working version
up and about. A version which will gzip text/html after res.render() / res.end() is in progress.
Expand Down
4 changes: 3 additions & 1 deletion lib/staticGzip.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ var gzippo = function(filename, charset, callback) {
* Options:
*
* - `maxAge` cache-control max-age directive, defaulting to 1 day
* - `clientMaxAge` client cache-control max-age directive, defaulting to 1 week
* - `matchType` - A regular expression tested against the Content-Type header to determine whether the response
* should be gzipped or not. The default value is `/text|javascript|json/`.
*
Expand All @@ -68,7 +69,8 @@ var gzippo = function(filename, charset, callback) {
exports = module.exports = function staticGzip(dirPath, options){
options = options || {};
var maxAge = options.maxAge || 86400000,
contentTypeMatch = options.contentTypeMatch || /text|javascript|json/;
contentTypeMatch = options.contentTypeMatch || /text|javascript|json/,
clientMaxAge = options.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

0 comments on commit d370626

Please sign in to comment.