What method is provided within the security API to prevent caching by browsers and proxies?
-
void setNoCacheHeaders(javax.servlet.http.HttpServletResponse response)
-
void setNoCacheHeaders(javax.servlet.http.HttpServletRequest request)
-
boolean setNoCacheHeader(javax.servlet.http.HttpServletResponse response)
-
void setNoCacheHeaders(javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException
Cache control headers must be set on the HttpServletResponse object, not the HttpServletRequest. The method returns void as it performs an action (setting headers) rather than returning a value. ServletException is not relevant to header operations, making option A the correct signature.
To stop sensitive pages from being cached by browsers or intermediate proxies, the utility method operates on the outgoing HttpServletResponse and sets headers like Cache-Control: no-cache, Pragma: no-cache, and Expires. It can't act on the HttpServletRequest since that represents the incoming request, and the method is a void action rather than something that returns a boolean or declares a checked exception.