Description
On 1.5, Image's onComponentTag() performs this:
if (AjaxRequestTarget.get() != null)
{ addAntiCacheParameter(tag); }The purpose here is to defeat browser's caching, However, sometimes the programmer has a unique URL to image and wishes the caching to occur, even for imags that are fetched by AJAX requests. An overridable method or property should be added to the Image class which controls whether the addAntiCacheParameter(tag) gets called. Perhaps something like defeatBrowserCache() with a javadoc that explains that for AJAX updates, the image's src attribute must be changed or browser will never fetch the image anew. Additionally, the method must be left as not final to allow subclasses to override it. Here's a suggestion:
/**
- The default behavior is to add wicket's anticaching url parameter
- to every image fetched via AJAX request. This is because browsers
- never examine their caches and fetch image data anew when
- parts of the page is redrawn by an AJAX request.
* - @param tag the component to be modified
*/
protected void defeatBrowserCache(ComponentTag tag) {
if (AjaxRequestTarget.get() != null) { addAntiCacheParameter(tag); }}
And this method should be called on the last lines of Image#onComponentTag().