New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cacheable-response

Package Overview
Dependencies
Maintainers
1
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cacheable-response - npm Package Compare versions

Comparing version 2.6.2 to 2.7.0

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

## 2.7.0 (2021-08-22)
### Features
* add EXPIRED cache state ([8a9eba7](https://github.com/Kikobeats/cacheable-response/commit/8a9eba73e6dacb5690f5cb83812656f6a4ff436b))
### 2.6.2 (2021-08-22)

@@ -7,0 +14,0 @@

2

package.json

@@ -5,3 +5,3 @@ {

"homepage": "https://nicedoc.io/Kikobeats/cacheable-response",
"version": "2.6.2",
"version": "2.7.0",
"main": "src/index.js",

@@ -8,0 +8,0 @@ "author": {

@@ -19,2 +19,12 @@ # cacheable-response

## Caching states
| Value | Description |
|----------|-------------------------------------------------------------------------------------------------------------------|
| `MISS` | The resource was looked into the cache but did not find it, so a new copy is generated and placed into the cache. |
| `HIT` | The resources was found into the cache, being generated by a previous access. |
| `EXPIRED`| The resouce was found but it is expired, being necessary regerate it. |
| `BYPASS` | The cache is forced to be bypassed, regenerating the resource. |
| `STALE` | The resource is expired but it's served while a new cache copy is generated in background. |
## Install

@@ -302,4 +312,3 @@

Note how in this second request `x-cache-status` is still
`MISS`.
Note how in this second request `x-cache-status` is still a `MISS`.

@@ -306,0 +315,0 @@ That's because CloudFlare way for caching the content includes caching the response headers.

@@ -82,10 +82,11 @@ 'use strict'

setHeaders({
createdAt,
etag,
res,
createdAt,
forceExpiration,
hasValue,
isHit,
isStale,
ttl,
res,
staleTtl,
forceExpiration
ttl
})

@@ -92,0 +93,0 @@

@@ -35,4 +35,12 @@ 'use strict'

const getStatus = ({ isHit, isStale, forceExpiration }) =>
isHit ? (isStale ? 'STALE' : 'HIT') : forceExpiration ? 'BYPASS' : 'MISS'
const getStatus = ({ hasValue, isHit, isStale, forceExpiration }) =>
isHit
? isStale
? 'STALE'
: 'HIT'
: forceExpiration
? 'BYPASS'
: hasValue
? 'EXPIRED'
: 'MISS'

@@ -43,2 +51,3 @@ const setHeaders = ({

forceExpiration,
hasValue,
isHit,

@@ -65,3 +74,3 @@ isStale,

'X-Cache-Status',
getStatus({ isHit, isStale, forceExpiration })
getStatus({ hasValue, isHit, isStale, forceExpiration })
)

@@ -68,0 +77,0 @@ res.setHeader('ETag', etag)

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc