Oracle WebCenter Interaction Web Service Development Guide

     Previous Next  Open TOC in new window   View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Setting HTTP Caching Headers - Cache-Control

The Cache-Control header can be used to expire content immediately or disable caching altogether. The value of this header determines whether cached pagelet/portlet content can be shared among different users.

The Cache-Control header can contain the following values:
public Allows any cached content to be shared across users with identical sets of preferences using the same portal server. This value should be used whenever possible.
private Tells the portal server not to share cached content. The User ID is added to the cache key so that a separate copy is retained in the cache for each individual user. This value should only be used to protect sensitive information, for example, an e-mail inbox portlet. (User settings can also make public content effectively private.)
max-age=[seconds] Specifies the maximum amount of time that an object is considered fresh. Similar to the Expires header, this directive allows more flexibility. [seconds] is the number of seconds from the time of the request that the object should remain fresh.
must-revalidate Tells the cache that it must obey any freshness information it receives about an object. HTTP allows caches to take liberties with the freshness of objects; specifying this header tells the cache to strictly follow your rules.
no-cache Disables caching completely and overrides Web Service editor settings. Neither the client nor the Portal Server responds to subsequent requests with a cached version.
In JSP, use the setHeader method to configure the Cache-Control header:
<%
response.setHeader("Cache-Control","public");
%>
The JSP example below expires the content immediately using the maximum age header.
<%
response.setHeader("Cache-Control","max-age=0");
%>
In .NET, the Cache-Control header is accessed through the System.Web.HttpCachePolicy class. To set the header to public, private or no-cache, use the Response.Cache.SetCacheability method.
Response.Cache.SetCacheability(HttpCacheability.Public);
To set a maximum age for content in .NET, use the Response.Cache.SetMaxAge method. The example below expires the content immediately.
TimeSpan ts = new TimeSpan(0,0,0);
Response.Cache.SetMaxAge(ts);
To set the header to must-revalidate in .NET, use the Response.Cache.SetRevalidation method.
Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);

  Back to Top      Previous Next