1

I'm trying to invalidate browser cache after 1 hour. In response header I have tried to add the following parameters.

Cache-Control:max-age=3600

Its working when I'm reloading the page or refreshing the page. But when using the back/forward button in browser it still loading from the browser. Is there any way /suggetsion to resolve this?

NB: When I googled it most the articles suggesting to use no-store parameter in Cache-Control. But at that time it will not use the browser cache all the time. And I need to use browser cache for first 1 hour after loading the page. After that it should load from server.

Eugène Adell
  • 3,089
  • 2
  • 18
  • 34
apm
  • 525
  • 6
  • 19
  • 1
    You could try the _Expires_ header but you want to do something that is not a recommended use of the browser history. Read [RFC 2616 13.13 History Lists](https://www.ietf.org/rfc/rfc2616.txt) to understand why _Cache-Control_ is not doing what you expected. – Eugène Adell Apr 10 '19 at 13:32
  • Thanks @EugèneAdell I went through that document. I hope that there is no direct way to achieve this in browser :) – apm Apr 11 '19 at 04:21
  • Have a look at this question [How to Detect Browser Back Button event - Cross Browser](https://stackoverflow.com/q/25806608/7748072) which talks about using JavaScript to track events particularly the _history back_. I believe this would override the default browser behavior, and then your _Cache-Control_ setting would be applied. Keep us informed if this worked. – Eugène Adell Apr 11 '19 at 05:22

0 Answers0