Socket
Socket
Sign inDemoInstall

http-cache-semantics

Package Overview
Dependencies
0
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.7.3 to 3.8.0

16

index.js

@@ -224,3 +224,10 @@ 'use strict';

const headers = this._copyWithoutHopByHopHeaders(this._resHeaders);
headers.age = `${Math.round(this.age())}`;
const age = this.age();
// A cache SHOULD generate 113 warning if it heuristically chose a freshness
// lifetime greater than 24 hours and the response's age is greater than 24 hours.
if (age > 3600*24 && !this._hasExplicitExpiration() && this.maxAge() > 3600*24) {
headers.warning = (headers.warning ? `${headers.warning}, ` : '') + '113 - "rfc7234 5.5.4"';
}
headers.age = `${Math.round(age)}`;
return headers;

@@ -264,2 +271,9 @@ }

/**
* Value of applicable max-age (or heuristic equivalent) in seconds. This counts since response's `Date`.
*
* For an up-to-date value, see `timeToLive()`.
*
* @return Number
*/
maxAge() {

@@ -266,0 +280,0 @@ if (!this.storable() || this._rescc['no-cache']) {

@@ -274,3 +274,10 @@ 'use strict';

var headers = this._copyWithoutHopByHopHeaders(this._resHeaders);
headers.age = '' + Math.round(this.age());
var age = this.age();
// A cache SHOULD generate 113 warning if it heuristically chose a freshness
// lifetime greater than 24 hours and the response's age is greater than 24 hours.
if (age > 3600 * 24 && !this._hasExplicitExpiration() && this.maxAge() > 3600 * 24) {
headers.warning = (headers.warning ? `${headers.warning}, ` : '') + '113 - "rfc7234 5.5.4"';
}
headers.age = `${Math.round(age)}`;
return headers;

@@ -318,2 +325,11 @@ };

/**
* Value of applicable max-age (or heuristic equivalent) in seconds. This counts since response's `Date`.
*
* For an up-to-date value, see `timeToLive()`.
*
* @return Number
*/
CachePolicy.prototype.maxAge = function maxAge() {

@@ -447,3 +463,3 @@ if (!this.storable() || this._rescc['no-cache']) {

if (this._resHeaders.etag) {
headers['if-none-match'] = headers['if-none-match'] ? headers['if-none-match'] + ', ' + this._resHeaders.etag : this._resHeaders.etag;
headers['if-none-match'] = headers['if-none-match'] ? `${headers['if-none-match']}, ${this._resHeaders.etag}` : this._resHeaders.etag;
}

@@ -537,3 +553,3 @@

method: this._method,
headers: headers
headers
});

@@ -540,0 +556,0 @@ return {

8

package.json
{
"name": "http-cache-semantics",
"version": "3.7.3",
"version": "3.8.0",
"description": "Parses Cache-Control and other headers. Helps building correct HTTP caches and proxies",

@@ -20,6 +20,6 @@ "repository": "https://github.com/pornel/http-cache-semantics.git",

"devDependencies": {
"babel-cli": "^6.24.0",
"babel-preset-env": "^1.3.2",
"mocha": "^3.2.0"
"babel-cli": "^6.24.1",
"babel-preset-env": "^1.5.2",
"mocha": "^3.4.2"
}
}

@@ -37,2 +37,8 @@ 'use strict';

it('IIS', function() {
const cache = new CachePolicy(req, {headers:{'cache-control': 'private, public, max-age=259200'}}, {shared:false});
assert(!cache.stale());
assert.equal(cache.maxAge(), 259200);
});
it('pre-check tolerated', function() {

@@ -39,0 +45,0 @@ const cc = 'pre-check=0, post-check=0, no-store, no-cache, max-age=100';

@@ -109,2 +109,3 @@ 'use strict';

assert.equal(headers['if-modified-since'], 'Tue, 15 Nov 1994 12:45:26 GMT');
assert(!/113/.test(headers.warning));
});

@@ -117,4 +118,18 @@

assertNoValidators(headers);
assert(!/113/.test(headers.warning));
})
it('113 added', function() {
const veryOldResponse = {
headers: {
age: 3600*72,
'last-modified': 'Tue, 15 Nov 1994 12:45:26 GMT',
},
};
const cache = new CachePolicy(simpleRequest, veryOldResponse);
const headers = cache.responseHeaders(simpleRequest);
assert(/113/.test(headers.warning));
})
});

@@ -121,0 +136,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with âšĄïž by Socket Inc