Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-3757

Image always noncaching when included in ajax request. However, sometimes caching image is desirable.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.5-RC4
    • 1.5-RC5
    • wicket

    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().

      Attachments

        Activity

          People

            mgrigorov Martin Tzvetanov Grigorov
            alankila Antti S. Lankila
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified