Comparing version 1.1.0 to 1.1.1
@@ -7,2 +7,9 @@ # Change Log | ||
## 1.1.1 | ||
_2020-04-27_ | ||
- fix: Skip internal caches when `config.cache === false` | ||
- fix: Set `max-age=0` for non-cached bundles | ||
## 1.1.0 | ||
@@ -9,0 +16,0 @@ |
{ | ||
"name": "cssserve", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -12,4 +12,4 @@ #!/usr/bin/env node | ||
var glob = require('glob'); | ||
var rc = _interopDefault(require('rc')); | ||
var LRUCache = _interopDefault(require('lru-cache')); | ||
var rc = _interopDefault(require('rc')); | ||
var path = require('path'); | ||
@@ -194,2 +194,26 @@ | ||
var name = "cssserve"; | ||
var normalizePathSlash = function (path) { return path.replace(/\/*$/, '/'); }; | ||
var appName = name.split('/').pop(); | ||
var HOUR = 60 * 60; | ||
var defaults = { | ||
port: 4000, | ||
staticFolder: 'public/', | ||
ttl_static: 24 * HOUR, | ||
ttl_bundle: 1 * HOUR, | ||
proxied: false, | ||
cache: true, | ||
}; | ||
var config = rc(appName, defaults); | ||
// enforce correct types | ||
config.port = parseInt(process.env.NODE_PORT || process.env.PORT || '') || config.port; | ||
config.staticFolder = normalizePathSlash(config.staticFolder.trim()); | ||
config.ttl_static = Number(config.ttl_static); | ||
config.ttl_bundle = Number(config.ttl_bundle); | ||
// config.cacheRefreshToken = | ||
config.cache = Boolean(config.cache); | ||
config.proxied = Boolean(config.proxied); | ||
config.sslKeyPath = config.sslKeyPath && config.sslKeyPath.trim(); | ||
var _validVersions = {}; | ||
@@ -203,3 +227,3 @@ onCacheRefresh(function () { | ||
} | ||
var versions = _validVersions[staticFolder]; | ||
var versions = config.cache && _validVersions[staticFolder]; | ||
if (!versions) { | ||
@@ -317,3 +341,3 @@ versions = _validVersions[staticFolder] = getAllValidCssVersions(staticFolder); | ||
var getDepsFor = function (file) { | ||
var deps = _depsCache[file]; | ||
var deps = config.cache && _depsCache[file]; | ||
if (!deps) { | ||
@@ -391,30 +415,4 @@ var css = fs.readFileSync(file, 'utf8'); | ||
var name = "cssserve"; | ||
var normalizePathSlash = function (path) { return path.replace(/\/*$/, '/'); }; | ||
var appName = name.split('/').pop(); | ||
var HOUR = 60 * 60; | ||
var defaults = { | ||
port: 4000, | ||
staticFolder: 'public/', | ||
ttl_static: 24 * HOUR, | ||
ttl_bundle: 1 * HOUR, | ||
proxied: false, | ||
cache: true, | ||
}; | ||
var config = rc(appName, defaults); | ||
// enforce correct types | ||
config.port = parseInt(process.env.NODE_PORT || process.env.PORT || '') || config.port; | ||
config.staticFolder = normalizePathSlash(config.staticFolder.trim()); | ||
config.ttl_static = Number(config.ttl_static); | ||
config.ttl_bundle = Number(config.ttl_bundle); | ||
// config.cacheRefreshToken = | ||
config.cache = Boolean(config.cache); | ||
config.proxied = Boolean(config.proxied); | ||
config.sslKeyPath = config.sslKeyPath && config.sslKeyPath.trim(); | ||
var ttl_bundle = config.ttl_bundle, staticFolder = config.staticFolder, cacheRefreshToken = config.cacheRefreshToken; | ||
var CACHE_CONTROL_VALUE = ttl_bundle | ||
? 'public, max-age=' + ttl_bundle + ', immutable' | ||
: undefined; | ||
var CACHE_CONTROL_VALUE = 'public, max-age=' + ttl_bundle + (ttl_bundle ? ', immutable' : ''); | ||
var bundleCache; | ||
@@ -462,5 +460,7 @@ var lastModified; | ||
} | ||
// Check if a cached result exists for the normalized version of the token list | ||
var normalizedTokens = versionFolder + '|' + modules.join(','); | ||
cachedBundle = bundleCache.get(normalizedTokens); | ||
if (cachedBundle) { | ||
// make the current url alias for the normalized token list | ||
bundleCache.set(url, cachedBundle); | ||
@@ -467,0 +467,0 @@ return cachedBundle; |
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
27380