|
Java™ by example!
|
|
|
How do I prevent the browser from caching the output of my servlet?
Setting "pragma: No-Cache" in servlet response should help:
public void doGet(HttpServletRequest req, HttpServletResponse resp) { // blah-blah... resp.addHeader("pragma", "No-Cache"); //.. here goes output }
|
But some broken web browsers (IE in particular) do not always honor this header. So a brute force approach may do: add to every URL you need non-cached some random parameter that your code will ignore. That is, if you have URL 'http://myhost/myservlet/param=1', turn it into something like 'http://myhost/myservlet/param=1&anticache=876348763458' and generate random values for 'anticache' parameter. This is known to work when IE tends to cache output which it should not.
Further Information
Author of answer: hal9000
Comments
Comments to this answer are only viewable by members. Login or become a member!
|
|
|
|
|