BackendStack21 / http-cache-middleware

HTTP Cache Middleware
MIT License
29 stars 2 forks source link

'cache-control': 'no-cache' is ignored #20

Open Fl0r14n opened 1 year ago

Fl0r14n commented 1 year ago

Describe the bug
Disable cache checkbox in browser is ignored

To Reproduce
1: enable Disable cache in browser 2: do the request twice 3: inspect response 4: x-cache-hit is 1

Expected behavior
The request is not cached

Screenshots
image

Desktop (please complete the following information):

Additional context
if (req.cacheDisabled) return next() does not seem to work

jkyberneees commented 1 year ago

Hi @Fl0r14n , thanks for reaching out. Disabling the cache in the browser will ONLY delete the local copy, but it won't make any effect on the server cache. The reason is that caches are not always tied to specific users and are expected to be shared. Please see: https://github.com/BackendStack21/http-cache-middleware#invalidating-caches

if (req.cacheDisabled) return next() does works as expected, please make sure that you are setting the attribute before the request reaches the middleware.

Regards