1. Public cache scope: the cache entries are shared across users
2. Validation based caching: expired cache entries can be validated using ETag
But there in JSR 168, only "Expiration" cache was supported. And also the cache is per user client and not shared across users.
Public Cache Scope You can tell the Portlet Container that the cache entry can be shared across users. This can be done by setting the value of

Validation based Caching Validation" caching is supported along with "Expiration" caching. After the cache has expired the portlet has the option to check if the cache is still valid and indicate that the cache can be reused. To enable this, ETag has been introduced, which is similar to how the browsers, which conform to HTTP 1.1, perform caching. Once the cache has expired the Portlet Container calls the render/serveResource method with the ETag set in the RenderRequest/ResourceRequest, which the portlet can access and check if the cache is still valid. If the cache is still valid, then the portlet can set CacheControl.setUseCachedContent(true) in the response, and the new expiration time.
protected void doView (RenderRequest request, RenderResponse response) throws PortletException, 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(“view.jsp”); rd.include(request, response);
}
The introduction of ETag ensures that the browser can be leveraged to cache resources and markup. With the new features of public sharing of caches, resource caching, validation caching and leveraging browser caching, the performance of aggregation of portlets by a portal can be seen to increase significantly.
No comments:
Post a Comment