Permalink
Browse files

Adding client max age directives

  • Loading branch information...
1 parent fb1f4d9 commit d3706262c0e73cc8e6b1f3b8ce3a34618001efd3 @tomgco tomgco committed Jul 20, 2011
Showing with 4 additions and 1 deletion.
  1. +1 −0 README.md
  2. +3 −1 lib/staticGzip.js
View
1 README.md
@@ -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.
View
4 lib/staticGzip.js
@@ -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/`.
*
@@ -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.');

0 comments on commit d370626

Please sign in to comment.