What is the correct way to set a response header to prevent caching of servlet responses?

  • setCacheControl("no-cache")
  • setHeader("Cache-Control", "no-store")
  • setHeader("Expires", "0")
  • setHeader("Pragma", "no-cache")
The correct way to set a response header to prevent caching is by using setHeader("Cache-Control", "no-store"), which instructs the browser not to store the response in its cache.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *