http-cache-middleware icon indicating copy to clipboard operation
http-cache-middleware copied to clipboard

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

Open Fl0r14n opened this issue 2 years ago • 1 comments

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):

  • OS: linux
  • Browser brave
  • Version chromium 107

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

Fl0r14n avatar Nov 17 '22 15:11 Fl0r14n

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

jkyberneees avatar Nov 18 '22 14:11 jkyberneees