express-istatic
Advanced tools
Comparing version 0.0.9-1 to 0.0.9-2
@@ -44,2 +44,4 @@ var uglify = require('./uglify.js'); | ||
opts = opts || options || defaultOptions; | ||
var str = read(path, opts) || ''; | ||
@@ -49,3 +51,3 @@ | ||
if (str.indexOf('#{') > -1) { | ||
compiled_fns[path] = function(locals) { | ||
var fn = function(locals) { | ||
return str.replace(reg_val, function(m0, m1) { | ||
@@ -56,3 +58,14 @@ var fn = new Function('locals', 'with (locals) { return ' + m1 + '; }'); | ||
}; | ||
return compiled_fns[path](this); | ||
var ttl = opts && opts.ttl || 0; | ||
if (!ttl && ttl !== 0 || ttl > 5) { | ||
compiled_fns[path] = fn; | ||
} | ||
if (ttl > 5) { | ||
setTimeout(function() { | ||
delete compiled_fns[path]; | ||
}, ttl * 1000); | ||
} | ||
return fn(this); | ||
} | ||
@@ -59,0 +72,0 @@ |
@@ -8,7 +8,7 @@ var fs = require('fs'); | ||
function waitStale(ttl, _t) { | ||
function globalStale(ttl, _t) { | ||
try { | ||
clearInterval(_t); | ||
} catch (e) {} | ||
_t = setInterval(function() { cache = {}; }, ttl * 1000); | ||
_t = setInterval(function() { global_cache = {}; }, ttl * 1000); | ||
} | ||
@@ -41,3 +41,4 @@ | ||
if (ttl > 5) { | ||
waitStale(ttl, _t); | ||
globalStale(ttl, _t); | ||
setInterval(function() { cache = {}; }, ttl * 1000); | ||
} else { | ||
@@ -79,2 +80,3 @@ // if the ttl is less than 5 seconds, | ||
log('Reading %s failed: %s', filepath, e); | ||
return ''; | ||
} | ||
@@ -81,0 +83,0 @@ |
{ | ||
"name": "express-istatic", | ||
"version": "0.0.9-1", | ||
"version": "0.0.9-2", | ||
"homepage": "http://github.com/ktmud/express-istatic", | ||
@@ -5,0 +5,0 @@ "description": "Add compressed inline css and scripts to your html, but write them as seperated files.", |
@@ -103,4 +103,6 @@ # Inline Static Files for express / connect / nodejs | ||
`filename` is the path of your static file. If it begins with a '/', the real path will be `process.cwd() + filename`. Otherwise, the file will be looked up from the root of your inline static files, as you configured before. | ||
`filename` is the path of your static file. | ||
If it begins with a `'/'`, the real path will be `process.cwd() + filename`. Otherwise, the file will be looked up from the root of your inline static files, as you configured before. | ||
You can set available options above, except for `root` and `ttl`. A `fresh` option is available for you to set this `istatic` call always read from file directly. | ||
@@ -107,0 +109,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13295
164
223