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 4.0.3 to 4.0.4

22

index.js

@@ -183,5 +183,5 @@ 'use strict';

// contains a public response directive.
this._rescc['max-age'] ||
(this._isShared && this._rescc['s-maxage']) ||
this._rescc.public ||
this._rescc['max-age'] ||
this._rescc['s-maxage'] ||
// has a status code that is defined as cacheable by default

@@ -346,8 +346,8 @@ statusCodeCacheableByDefault.indexOf(this._status) !== -1)

_serverDate() {
const dateValue = Date.parse(this._resHeaders.date);
if (isFinite(dateValue)) {
const serverDate = Date.parse(this._resHeaders.date);
if (isFinite(serverDate)) {
const maxClockDrift = 8 * 3600 * 1000;
const clockDrift = Math.abs(this._responseTime - dateValue);
const clockDrift = Math.abs(this._responseTime - serverDate);
if (clockDrift < maxClockDrift) {
return dateValue;
return serverDate;
}

@@ -424,10 +424,10 @@ }

const dateValue = this._serverDate();
const serverDate = this._serverDate();
if (this._resHeaders.expires) {
const expires = Date.parse(this._resHeaders.expires);
// A cache recipient MUST interpret invalid date formats, especially the value "0", as representing a time in the past (i.e., "already expired").
if (Number.isNaN(expires) || expires < dateValue) {
if (Number.isNaN(expires) || expires < serverDate) {
return 0;
}
return Math.max(defaultMinTtl, (expires - dateValue) / 1000);
return Math.max(defaultMinTtl, (expires - serverDate) / 1000);
}

@@ -437,6 +437,6 @@

const lastModified = Date.parse(this._resHeaders['last-modified']);
if (isFinite(lastModified) && dateValue > lastModified) {
if (isFinite(lastModified) && serverDate > lastModified) {
return Math.max(
defaultMinTtl,
((dateValue - lastModified) / 1000) * this._cacheHeuristic
((serverDate - lastModified) / 1000) * this._cacheHeuristic
);

@@ -443,0 +443,0 @@ }

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

@@ -5,0 +5,0 @@ "repository": "https://github.com/kornelski/http-cache-semantics.git",

@@ -148,3 +148,3 @@ # Can I cache this? [![Build Status](https://travis-ci.org/kornelski/http-cache-semantics.svg?branch=master)](https://travis-ci.org/kornelski/http-cache-semantics)

// Send request to the origin server. The server may respond with status 304
const newResponse = await makeRequest(newResponse);
const newResponse = await makeRequest(newRequest);

@@ -151,0 +151,0 @@ // Create updated policy and combined response from the old and new data

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