semantic-network
Advanced tools
Comparing version 0.7.35 to 0.7.36
@@ -217,3 +217,3 @@ "use strict"; | ||
var _d = this.getState(resource).headers, headers = _d === void 0 ? {} : _d; | ||
var _e = headers["expires"], expires = _e === void 0 ? undefined : _e, _f = headers["last-modified"], lastModified = _f === void 0 ? undefined : _f, _g = headers["cache-control"], cacheControl = _g === void 0 ? undefined : _g; | ||
var _e = headers["expires"], expires = _e === void 0 ? undefined : _e, _f = headers["cache-control"], cacheControl = _f === void 0 ? undefined : _f, _g = headers["date"], date = _g === void 0 ? undefined : _g; | ||
var now = new Date(); | ||
@@ -225,8 +225,11 @@ /* | ||
* The main issue is whether "time" is up and a potential refresh is required. This calculation is the | ||
* last-modified + max-age. However, the server provides this as an absolute date in the expires header. | ||
* last-modified + max-age. The server provides this as an absolute date in the expires header. | ||
*/ | ||
if (checkExpiresHeader && expires) { | ||
// TODO: be able to inject this as a override-able strategy | ||
return now > new Date(expires); | ||
} | ||
// TODO: be able to inject this as a override-able strategy | ||
if (checkCacheControlHeader && cacheControl) { | ||
// TODO: be able to inject this as a override-able strategy | ||
var _h = (0, cache_control_parser_1.parse)(cacheControl), _j = _h["max-age"], maxAge = _j === void 0 ? undefined : _j, _k = _h["no-cache"], noCache = _k === void 0 ? undefined : _k; | ||
@@ -236,6 +239,7 @@ if (maxAge === 0 || noCache) { | ||
} | ||
if (lastModified && maxAge) { | ||
var date = new Date(lastModified); | ||
date.setSeconds(date.getSeconds() + maxAge || 0); | ||
return now > date; | ||
// date will need to be exposed (eg as CORS headers—Access-Control-Expose-Headers: Date) | ||
if (date && maxAge) { | ||
var d = new Date(date); | ||
d.setSeconds(d.getSeconds() + maxAge || 0); | ||
return now > d; | ||
} | ||
@@ -242,0 +246,0 @@ } |
@@ -173,3 +173,3 @@ import { LinkUtil } from 'semantic-link'; | ||
const { headers = {} } = this.getState(resource); | ||
const { 'expires': expires = undefined, 'last-modified': lastModified = undefined, 'cache-control': cacheControl = undefined, } = headers; | ||
const { 'expires': expires = undefined, 'cache-control': cacheControl = undefined, 'date': date = undefined, } = headers; | ||
const now = new Date(); | ||
@@ -181,8 +181,11 @@ /* | ||
* The main issue is whether "time" is up and a potential refresh is required. This calculation is the | ||
* last-modified + max-age. However, the server provides this as an absolute date in the expires header. | ||
* last-modified + max-age. The server provides this as an absolute date in the expires header. | ||
*/ | ||
if (checkExpiresHeader && expires) { | ||
// TODO: be able to inject this as a override-able strategy | ||
return now > new Date(expires); | ||
} | ||
// TODO: be able to inject this as a override-able strategy | ||
if (checkCacheControlHeader && cacheControl) { | ||
// TODO: be able to inject this as a override-able strategy | ||
const { 'max-age': maxAge = undefined, 'no-cache': noCache = undefined, } = parse(cacheControl); | ||
@@ -192,6 +195,7 @@ if (maxAge === 0 || noCache) { | ||
} | ||
if (lastModified && maxAge) { | ||
const date = new Date(lastModified); | ||
date.setSeconds(date.getSeconds() + maxAge || 0); | ||
return now > date; | ||
// date will need to be exposed (eg as CORS headers—Access-Control-Expose-Headers: Date) | ||
if (date && maxAge) { | ||
const d = new Date(date); | ||
d.setSeconds(d.getSeconds() + maxAge || 0); | ||
return now > d; | ||
} | ||
@@ -198,0 +202,0 @@ } |
{ | ||
"name": "semantic-network", | ||
"version": "0.7.35", | ||
"version": "0.7.36", | ||
"description": "A utility library for manipulating a list of links that form a semantic interface to a network of resources.", | ||
@@ -5,0 +5,0 @@ "main": "lib/es5/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1276114
20903