setMaxAge

This function can be used to set an absolute time for an expiration of a page. This is best used for pages with a long life that may be requested frequently. Due to problems in time synchronization between the client and the server, it is not totally reliable, especially for short-lived caches. The data must follow one of the acceptable HTTP date formats.

Refer to the W3 Protocols for more information:

http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3

Type and Usage

Parameters

The only parameter is the lifetime of this page in seconds.

Output

  • Returns TRUE if the function is successful.

  • Returns FALSE if the function fails.

Example

This will expire the content of the page immediately:

<$setMaxAge(0)$> 

This will set the cache lifetime for this page to 10 minutes, and tell the browser that it absolutely must try to refresh the page after that time is up:

<$setMaxAge(600)$>
<$setHttpHeader("Cache-Control", "must-revalidate")$> 

See Also