Wicket
  1. Wicket
  2. WICKET-3757

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

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5-RC4
    • Fix Version/s: 1.5-RC5
    • Component/s: wicket
    • Labels:

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

        Activity

        Hide
        Martin Grigorov added a comment -

        With r1132923 the check whether to add the anti cache parameter is moved to overridable method org.apache.wicket.markup.html.image.Image.shouldAddAntiCacheParameter().

        Show
        Martin Grigorov added a comment - With r1132923 the check whether to add the anti cache parameter is moved to overridable method org.apache.wicket.markup.html.image.Image.shouldAddAntiCacheParameter().

          People

          • Assignee:
            Martin Grigorov
            Reporter:
            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

                Development