Alexander Mills
Alexander Mills

Reputation: 100290

Prevent any caching in the browser

Which header(s) can I use to prevent any caching on the part of the browser?

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control

would it simply be:

res.setHeader('cache-control','no-cache');

Upvotes: 0

Views: 46

Answers (2)

M Nottingham
M Nottingham

Reputation: 5804

Cache-Control: no-store is sufficient.

See: https://www.mnot.net/blog/2017/03/16/browser-caching

Upvotes: 4

Alexander Mills
Alexander Mills

Reputation: 100290

Looks like this is the most comprehensive thing to do:

  res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');

according to: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control

but I guess one thing I don't understand - it seems like must-revalidate is redundant - I figure that no-cache/no-store already takes care of must-revalidate would otherwise do?

Upvotes: 1

Related Questions