Skip to content

Commit

Permalink
add no-cache option to #49
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydaly committed Aug 14, 2018
1 parent ca795bc commit d0590a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/response.js
Expand Up @@ -373,7 +373,9 @@ class RESPONSE {
// if custom string value
if (maxAge !== true && maxAge !== undefined && typeof maxAge === 'string') {
this.header('Cache-Control', maxAge)
} else if (maxAge !== false) {
} else if (maxAge === false) {
this.header('Cache-Control', 'no-cache, no-store, must-revalidate')
} else {
maxAge = maxAge && !isNaN(maxAge) ? (maxAge/1000|0) : 0
this.header('Cache-Control', (isPrivate === true ? 'private, ' : '') + 'max-age=' + maxAge)
this.header('Expires',new Date(Date.now() + maxAge).toUTCString())
Expand Down
3 changes: 2 additions & 1 deletion test/cacheControl.js
Expand Up @@ -106,7 +106,8 @@ describe('cacheControl Tests:', function() {
let result = await new Promise(r => api.run(_event,{},(e,res) => { r(res) }))
expect(result).to.deep.equal({
headers: {
'content-type': 'application/json'
'content-type': 'application/json',
'cache-control': 'no-cache, no-store, must-revalidate'
},
statusCode: 200,
body: 'cache',
Expand Down

0 comments on commit d0590a7

Please sign in to comment.