1

What I want to do is refreshing the view on back key. So that my user can see updated page.

So I tried to disable cache by adding:

spring.resources.cache.cachecontrol.no-cache=true

However, it doesn't work.

John
  • 1,139
  • 3
  • 16
  • 33
  • 1
    I'm fairly certain that browsers will load a cached version regardless of your cache control header configuration if you use the browser history (eg. a back button). JavaScript code is still executed though, and by creating a proper event listener, you should be able to reload a page in case you're using the back button, as mentioned in [this question](https://stackoverflow.com/questions/43043113/how-to-force-reloading-a-page-when-using-browser-back-button). – g00glen00b Mar 08 '19 at 09:26

1 Answers1

5

You can specify which cache type to use by adding spring.cache.type to your configuration. To disable it set the value to NONE.

spring.cache.type=NONE
Romil Patel
  • 12,879
  • 7
  • 47
  • 76
  • 1
    [https://docs.spring.io/spring-boot/docs/2.1.6.RELEASE/reference/html/boot-features-caching.html](spring cache) according to this documentation it mentions: When @EnableCaching is present in your configuration, a suitable cache configuration is expected as well. If you need to disable caching altogether in certain environments, force the cache type to none to use a no-op implementation, as shown in the following example: – jkamcc Aug 11 '21 at 12:06
  • @jkamcc This link is broken unfortunately, and I'm really curious about "the following example" :P haha – Alexandre Cassagne Nov 29 '22 at 15:36