portletspec3
  1. portletspec3
  2. PORTLETSPEC3-19

Errata: Clarify when CacheControl parameters can be set

    Details

      Description

      CacheControl parameters need to be set in the HTTP header before the response is
      written.

      Working Document 3 (22.04.13) Section "PLT.22.2 Validation Cache", page 164 line 4 states:
      -------------------------
      The portlet should set the validation token, expiry time or caching scope before
      writing to the output stream as otherwise portals / portlet containers may ignore the
      values.
      -------------------------

      This is correct. However, the example right below that shows such parameters being set
      in the doView method:

      -------------------------
      protected void doView (RenderRequest request, RenderResponse response)
      throws PortletException, java.io.IOException
      {
      ...
      if ( request.getETag() != null ) { // validation request
      if ( markupIsStillValid(request.getETag()) ) {
      // markup is still valid
      response.getCacheControl().setExpirationTime(30);
      response.getCacheControl().setUseCachedContent(true);
      return;
      }
      }
      // create new content with new validation tag
      response.getCacheControl().setETag(someID);
      response.getCacheControl().setExpirationTime(60);
      PortletRequestDispatcher rd =
      getPortletContext().getPortletRequestDispatcher("jsp/view.jsp");
      rd.include(request, response);
      }
      -------------------------

      In general, this example would not work. Instead, the example code should
      appear in the doHeaders method, as follows:

      Corrected:
      -------------------------
      protected void doHeaders (RenderRequest request, RenderResponse response)
      {
      ...
      if ( request.getETag() != null ) { // validation request
      if ( markupIsStillValid(request.getETag()) ) {
      // markup is still valid
      response.getCacheControl().setExpirationTime(30);
      response.getCacheControl().setUseCachedContent(true);
      return;
      }
      }
      // create new content with new validation tag
      response.getCacheControl().setETag(someID);
      response.getCacheControl().setExpirationTime(60);
      PortletRequestDispatcher rd =
      getPortletContext().getPortletRequestDispatcher("jsp/view.jsp");
      rd.include(request, response);
      }
      -------------------------

        Activity

        Hide
        msnicklous added a comment -

        Fix discussed on 20130723 and was accepted.

        Show
        msnicklous added a comment - Fix discussed on 20130723 and was accepted.
        Hide
        msnicklous added a comment -

        Updated spec document accordingly.

        Show
        msnicklous added a comment - Updated spec document accordingly.

          People

          • Assignee:
            msnicklous
            Reporter:
            msnicklous
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: