On 01/03/06, Anders Peterson <[EMAIL PROTECTED]> wrote: > 3) "Set the headers on the response": You mean some header that tells > the browser(s) not to cache the page - is there a standard for that?
Quite a few, all covering different aspects of your problem! :-) > I have no idea which browsers will be used, and I want the app to work > with any browser. You're not alone, but you're trying to herd cats... :-) This seems to be a good summary of the state of things, from the 2nd page of replies to at "http://www.jguru.com/faq/view.jsp?EID=377" "The answer here is incomplete. First of all you have to remember that these directives are used by all downstream caches (proxy servers and the browser) and therefore what might work in one situation (say, a direct connection between web server and client) may not work if there is a caching proxy server in between if the cache control headers are not thought through carefully. Taking the directives in turn: response.setHeader("Pragma", "no-cache"); This is the only cache control directive for HTTP 1.0, so should feature in addition to any HTTP 1.1 cache control headers you include. response.setHeader("Cache-Control", "no-cache"); // HTTP 1.1 This directive does NOT prevent caching despite its name. It allows caching of the page, but specifies that the cache must ask the originating web server if the page is up-to-date before serving the cached version. So the cached page can still be served up i- f the originating web server says so. Applies to all caches. response.setDateHeader ("Expires", 0); // HTTP 1.1 This tells the browser that the page has expired and must be treated as stale. Should be good news as long as the caches obey. So, what is missing? In my book you should also add: response.setHeader("Cache-Control", "private"); // HTTP 1.1 This specifies that the page contains information intended for a single user only and must not be cached by a shared cache (e.g. a proxy server). response.setHeader("Cache-Control", "no-store"); // HTTP 1.1 This specifies that a cache must NOT store any part of the response or the request that elicited it. Adding these two headers should prevent the caching of pages anywhere between the web server and browser, as well as in the browser itself. The meaning of each directive is very specific and so a given combination of directives has a different effect in any one environment. You can also consider adding: response.setHeader("Cache-Control", "max-stale=0"); // HTTP 1.1 This tells the cache that the maximum acceptable staleness of a page is 0 seconds. Things to avoid doing: The use of <meta http-equiv="expires" content=<%= new java.util.Date() %>> basically says 'this page is valid until "now" (date generated at server)'. It is fraught with peril! If the client time is,say, a minute behind the server time, then the page will be cached in the client for a minute. Much safer to use <meta http-equiv="expires" content="0"> which must always be treated as stale content. If you specify all of the following: response.setDateHeader ("Expires", 0); response.setHeader("Cache-Control","private"); response.setHeader("Cache-Control","max-age=0"); Then the third directive OVERRIDES both the first AND second! Incidentally response.setHeader(<attr>, <value>) is 100% euqivalent to <meta http-equiv="<attr>" content="<value>"> and the order of the headers is not significant. Check out the official (theoretical) line at http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html - sections 14.9 and 14.21" > > Thanks, /Anders > > > Anders Peterson wrote: > > Hi, > > > > On one page I'm displaying dynamic charts (JFreeChart) as images. The > > charts, the data they're based on, are constantly changed by the users. > > > > The problem (as I understand it): The web browser doesn't know that the > > image has changed and therefore (sometimes) uses a cached image. Which > > means incorrect data is displayed. > > > > How can I make sure the browser always asks for a fresh image? > > > > /Anders > > > > > > Image tmpImage2 = new Image("image2", new SpclChartResource() { > > > > public AbstractChartFactory getFactory() { > > > > this.setHeight(300); > > this.setWidth(600); > > > > DefaultCategoryDatasetFactory retVal = new > > DefaultCategoryDatasetFactory(); > > retVal.setLegend(true); > > retVal.setType(AbstractChartFactory.TYPE_BarChart); > > ... > ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642 _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user