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.
Loading...
Related Quiz
- To optimize performance, a servlet should cache frequently used data in the ________.
- What is the primary interface used for file upload in servlets?
- Which method is used to initialize a filter in the filter chain?
- How can servlets be effectively used to implement the front controller pattern in an MVC application?
- Which HTTP status code is typically sent by an HTTP servlet to indicate a successful response?