Skip to content

Commit d0590a7

Browse files
committed
add no-cache option to #49
1 parent ca795bc commit d0590a7

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/response.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,9 @@ class RESPONSE {
373373
// if custom string value
374374
if (maxAge !== true && maxAge !== undefined && typeof maxAge === 'string') {
375375
this.header('Cache-Control', maxAge)
376-
} else if (maxAge !== false) {
376+
} else if (maxAge === false) {
377+
this.header('Cache-Control', 'no-cache, no-store, must-revalidate')
378+
} else {
377379
maxAge = maxAge && !isNaN(maxAge) ? (maxAge/1000|0) : 0
378380
this.header('Cache-Control', (isPrivate === true ? 'private, ' : '') + 'max-age=' + maxAge)
379381
this.header('Expires',new Date(Date.now() + maxAge).toUTCString())

test/cacheControl.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ describe('cacheControl Tests:', function() {
106106
let result = await new Promise(r => api.run(_event,{},(e,res) => { r(res) }))
107107
expect(result).to.deep.equal({
108108
headers: {
109-
'content-type': 'application/json'
109+
'content-type': 'application/json',
110+
'cache-control': 'no-cache, no-store, must-revalidate'
110111
},
111112
statusCode: 200,
112113
body: 'cache',

0 commit comments

Comments
 (0)