[PORTLETSPEC3-19] Errata: Clarify when CacheControl parameters can be set Created: 03/May/13  Updated: 26/Jul/13  Resolved: 09/Jul/13

Status: Closed
Project: portletspec3
Component/s: JSR 286 Portlet Specification Errata
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: msnicklous Assignee: msnicklous
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 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);
}
-------------------------



 Comments   
Comment by msnicklous [ 09/Jul/13 ]

Updated spec document accordingly.

Comment by msnicklous [ 26/Jul/13 ]

Fix discussed on 20130723 and was accepted.

Generated at Mon Mar 30 07:41:08 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.