cacheable-response
Advanced tools
Comparing version
@@ -5,2 +5,10 @@ # Changelog | ||
## [1.8.0](https://github.com/Kikobeats/cacheable-response/compare/v1.7.5...v1.8.0) (2019-10-30) | ||
### Features | ||
* return 304 when If-None-Match matches ETag ([ca08d9b](https://github.com/Kikobeats/cacheable-response/commit/ca08d9b877600fbf2e4c2bb73a041676cd7002c2)), closes [#31](https://github.com/Kikobeats/cacheable-response/issues/31) | ||
* return 304 when If-None-Match matches ETag ([#32](https://github.com/Kikobeats/cacheable-response/issues/32)) ([ef672a1](https://github.com/Kikobeats/cacheable-response/commit/ef672a17a77c927dcb5c344d5a578bfbfa9167a5)) | ||
### [1.7.5](https://github.com/Kikobeats/cacheable-response/compare/v1.7.4...v1.7.5) (2019-10-30) | ||
@@ -7,0 +15,0 @@ |
11
index.js
@@ -102,2 +102,4 @@ 'use strict' | ||
const etag = cachedEtag || getEtag(serialize(data)) | ||
const ifNoneMatch = req.headers['if-none-match'] | ||
const isModified = etag !== ifNoneMatch | ||
@@ -109,3 +111,4 @@ debug({ | ||
result: !isEmpty(result), | ||
etag | ||
etag, | ||
ifNoneMatch | ||
}) | ||
@@ -122,2 +125,8 @@ | ||
if (!isModified) { | ||
res.statusCode = 304 | ||
res.end() | ||
return | ||
} | ||
if (!isHit) { | ||
@@ -124,0 +133,0 @@ const payload = { etag, createdAt, ttl, data, ...props } |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://nicedoc.io/Kikobeats/cacheable-response", | ||
"version": "1.7.5", | ||
"version": "1.8.0", | ||
"main": "index.js", | ||
@@ -14,4 +14,14 @@ "author": { | ||
"contributors": [ | ||
"rickynyairo <rickynyairo@gmail.com>", | ||
"whooehoo <whooehoo@yandex.ru>" | ||
{ | ||
"name": "Jakub Sarnowski", | ||
"email": "jakub.sarnowski.st-yl.com" | ||
}, | ||
{ | ||
"name": "rickynyairo", | ||
"email": "rickynyairo@gmail.com" | ||
}, | ||
{ | ||
"name": "whooehoo", | ||
"email": "whooehoo@yandex.ru" | ||
} | ||
], | ||
@@ -75,13 +85,13 @@ "repository": { | ||
"clean": "rm -rf node_modules", | ||
"contributors": "(git-authors-cli && finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"lint": "standard-markdown README.md && standard", | ||
"postrelease": "npm run release:tags && npm run release:github && ci-publish", | ||
"prerelease": "npm run update:check", | ||
"prerelease": "npm run update:check && npm run contributors", | ||
"pretest": "npm run lint", | ||
"pretty": "prettier-standard index.js {core,test,bin,scripts}/**/*.js --single-quote --print-width 100", | ||
"release": "git-authors-cli && git add package.json && standard-version -a", | ||
"release": "standard-version -a", | ||
"release:github": "conventional-github-releaser -p angular", | ||
"release:tags": "git push --follow-tags origin HEAD:master", | ||
"test": "nyc ava", | ||
"update": "ncu -a", | ||
"update": "ncu -u", | ||
"update:check": "ncu -- --error-level 2" | ||
@@ -88,0 +98,0 @@ }, |
27022
3.59%119
7.21%