reliable-get
Advanced tools
Comparing version 0.1.29 to 0.1.30
@@ -84,3 +84,5 @@ 'use strict'; | ||
res.headers = res.headers || {}; | ||
res.headers['cache-control'] = 'no-cache, no-store, must-revalidate'; | ||
if (!hasCacheControl(res, 'no-cache') || !hasCacheControl(res, 'no-store')) { | ||
res.headers['cache-control'] = 'no-cache, no-store, must-revalidate'; | ||
} | ||
next(null, {statusCode: res.statusCode, content: res.content, headers: res.headers, timing: res.timing}); | ||
@@ -87,0 +89,0 @@ }); |
{ | ||
"name": "reliable-get", | ||
"version": "0.1.29", | ||
"version": "0.1.30", | ||
"description": "A circuit breaker and cached wrapper for GET requests (enables reliable external service interaction).", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -69,2 +69,13 @@ 'use strict'; | ||
it('NO CACHE: should just request service if explicitNoCache', function(done) { | ||
var config = {cache:{engine:'nocache'}}; | ||
var rg = new ReliableGet(config); | ||
rg.get({url:'http://localhost:5001/nocachecustom', explicitNoCache: true}, function(err, response) { | ||
expect(err).to.be(null); | ||
expect(response.headers['cache-control']).to.be('no-cache, no-store, must-revalidate, private, max-stale=0, post-check=0, pre-check=0'); | ||
expect(response.statusCode).to.be(200); | ||
done(); | ||
}); | ||
}); | ||
it('NO CACHE: should fail if timeout exceeded', function(done) { | ||
@@ -229,2 +240,3 @@ var config = {cache:{engine:'nocache'}}; | ||
expect(response.statusCode).to.be(200); | ||
expect(response.headers['cache-control']).to.be('private, max-age=0, no-cache'); | ||
var content = response.content; | ||
@@ -234,2 +246,3 @@ setTimeout(function() { | ||
expect(response.statusCode).to.be(200); | ||
expect(response.headers['cache-control']).to.be('private, max-age=0, no-cache'); | ||
expect(response.content).to.not.be(content); | ||
@@ -236,0 +249,0 @@ done(); |
@@ -44,2 +44,7 @@ 'use strict'; | ||
router.get('/nocachecustom', function(req, res) { | ||
res.writeHead(200, {'cache-control': 'no-cache, no-store, must-revalidate, private, max-stale=0, post-check=0, pre-check=0'}); | ||
res.end('' + Date.now()); | ||
}); | ||
router.get('/maxage', function(req, res) { | ||
@@ -46,0 +51,0 @@ res.writeHead(200, {'cache-control': 'private, max-age=5000'}); |
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
33629239
1121