Effect of setCacheability on resource URL

With the setCacheability method on the ResourceURL the portlet can indicate that it only needs parts of the overall state via the cache level parameter and thus the portal application can create URLs that result in an increased likelihood of a subsequent browser access being served from a browser/web cache. With the getCachability method on the ResourceURL the portlet can retrieve the current cache level.


  • FULL – The resource URL does not need to contain the current state of the page or the current render parameters, portlet mode, or window state of the portlet. Thus the portlet should not access the portlet mode, window state, or render parameters in the serveResource call.URLs of the type FULL have the highest cacheability in the browser as they do not depend on any state of the portlet or page.

  • PORTLET – The serveResource call triggered by a PORTLET resource URL does have access to the portlet state consisting of the render parameters, portlet mode and window state.URLs of the type PORTLET are cacheable on the portlet level in the browser and can be served from the browser cache for as long as the state of this portlet does not change

  • PAGE – The resource URL may contain artifacts that require knowledge of the state of the complete page, like PortletURLs, or resource URLs of type PAGE. The markup returned by such a resource URL may contain any portlet URL. Resource URLs of the type PAGE are only cacheable on the page level and can only be served from the browser cache as long as no state on the page changes.



I tried building a sample URLCacheabilityPortlet to see how the URL Cacheability works but it seems that it does not work as described in the portlet specification either in the Apache Pluto or WebSphere Pluto, but i could see that portal server is generating different URLs for serveResource depending on the Cacheability level

public class URLCacheabilityPortlet extends GenericPortlet{
protected void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
System.out.println("Entering URLCacheabilityPortlet.doView()");
response.setContentType("text/html");
getPortletContext().getRequestDispatcher("/view.jsp").include(request, response);
System.out.println("Exiting URLCacheabilityPortlet.doView()");
}
public void serveResource(ResourceRequest request, ResourceResponse response)
throws PortletException, IOException {
System.out.println("Entering URLCacheabilityPortlet.serveResource()");
response.setContentType("text/html");

ResourceURL fullCachableURL = response.createResourceURL();
fullCachableURL.setCacheability(ResourceURL.FULL);
fullCachableURL.setProperty(ResourceURL.SHARED, "TestQName");
request.setAttribute("fullCachableUrl", fullCachableURL.toString());

ResourceURL pageCachableURL = response.createResourceURL();
pageCachableURL.setCacheability(ResourceURL.PAGE);
request.setAttribute("pageCachableURL", pageCachableURL.toString());

ResourceURL portletCacheableURL = response.createResourceURL();
portletCacheableURL.setCacheability(ResourceURL.PORTLET);
request.setAttribute("portletCacheableURL", portletCacheableURL.toString());
getPortletContext().getRequestDispatcher("/index.jsp").include(request, response);
System.out.println("Entering URLCacheabilityPortlet.serveResource()");
}
}


When i did add two instances of this portlet on one websphere portal page this is the output that i got