I want to ensure that my servet's response is never cached by the broswer, such that even if two identical requests are made (a nanosecond apart), the server is always contacted. Is this the correct way to achieve this:
class MyServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
response.setHeader("Cache-Control", "no-cache");
}
}
Thanks, Don
According to microsoft, these headers are required for IE:
Example:
No, that's not the correct way. Here is the correct way:
You'll probably see someone else suggesting other entries/attributes, but those are completely irrelevant when at least the above are mentioned.
Don't forget to clear your browser cache before testing after the change.
See also:
We use: