AquaLogic User Interaction 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 - Expires

The Expires header specifies when content will expire, or how long content is “fresh.” After this time, the Portal Server will always check back with the remote server to see if the content has changed.

Most Web servers allow setting an absolute time to expire, a time based on the last time that the client saw the object (last access time), or a time based on the last time the document changed on your server (last modification time).
In JSP, setting caching to forever using the Expires header is as simple as using the code that follows:
<%
response.setDateHeader("Expires",Long.MAX_VALUE);
%>
The .NET Framework’s System.Web.HttpCachePolicy class provides a range of methods to handle caching, but it can also be used to set HTTP headers explicitly (see MSDN for API documentation: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebhttpcachepolicyclasssetexpirestopic.asp). The Response.Cache.SetExpires method allows you to set the Expires header in a number of ways. The following code snippet sets it to forever:
Response.Cache.SetExpires(DateTime.Now.AddYears(100000000));
In .NET, the Web Form page (.aspx) can also use standard ASP methods to set HTTP headers.
Note: Never use Expires = 0 to prevent caching. The Expires header is sent by the remote server and passed through to the browser by the Portal Server. Unless the time on all three machines is synchronized, an Expires=0 header can mistakenly return cached content. To solve this problem, set the Expires header to a fixed date that is definitely in the past.

  Back to Top      Previous Next