Skip to content

Commit

Permalink
preparation for 5.1.0 release (#46)
Browse files Browse the repository at this point in the history
* docs: update readme for cacheStatusHeader

* chore: update CHANGELOG

* feat: update types for cacheStatusHeader

* chore: bump package to 5.1.0
  • Loading branch information
evanshortiss authored Jun 10, 2019
1 parent 0a8fb14 commit a673f22
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

Dates are YYYY-MM-DD.

## 5.0.1 / 2019-05-10
## 5.1.0 / 2019-05-10
* Add `cacheStatusHeader` option to rename or disable `x-expeditious-cache'`
headers
* Fix issue `res.socket` was `undefined` when attempting to write
* Update dependencies and devDependencies for bug/security fixes

Expand Down
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,6 @@ And here's one not using `express-session`:
GET-/cached
```


#### Custom
You can define custom a custom key for incoming requests by providing a
_genCacheKey_ option when creating _express-expeditious_ instances.
Expand Down Expand Up @@ -493,6 +492,36 @@ const versionlessCache = cache.withCacheKey((req, res) => {
});
```

### Hit/Miss Header (_cacheStatusHeader_)

#### Default
An `x-expeditious-cache` header is returned in each response with the value of
`hit` or `miss` to indicate if the request was served by the cache.

#### Custom
Passing the `cacheStatusHeader` option can change the name of the header from
`x-expeditious-cache` to a value of your choosing by passing a string. You can
also pass the boolean value `false` to disable the header entirely.

```js
const cache = expressExpeditious({
defaultTtl: '1 hour',
namespace: 'mycache',

// Disable sending the header
cacheStatusHeader: false
})

const cache = expressExpeditious({
defaultTtl: '1 minute',
namespace: 'my-other-cache',

// Change the header name
cacheStatusHeader: 'x-cache-status'
})
```


### Status Code Variations (_statusCodeExpires_ or _withTtlForStatus_)

#### Default
Expand Down
3 changes: 1 addition & 2 deletions express-expeditious.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ declare namespace ExpressExpeditious {
namespace: string
engine?: any
sessionAware?: boolean
cacheStatusHeader?: boolean | string

cacheStatusHeader?: boolean|string
genCacheKey?: GenreateCacheKeyFunction
shouldCache?: ShouldCacheFunction
statusCodeExpires?: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "express-expeditious",
"version": "5.0.0",
"version": "5.1.0",
"description": "express caching middlware",
"main": "lib/middleware.js",
"files": [
Expand Down

0 comments on commit a673f22

Please sign in to comment.