System Template
cache()
Allows the web page to specify whether stations on the network
should cache this page.
See Also
<rb:cachecontrol...> Syntax
void = rb.page.cache(cache, private, expires)
Parameters
The 'cache' method takes 3 parameters:
Name | Type/Value | Range/Length | Description | cache | bool | | Optional.
Specifies whether to allow network devices to cache this page. By default
the presentation engine prohibits caching by intermediate devices.
| private | bool | | Optional, default = false
Used *if* 'cache' is set to 'true'. If so - then this parameter specified whether
the page to be cached contains client private data. If so then this value -
set to 'true' - will prevent intermediate caches from storing the data
and serving that to someone else.
| expires | number | | Optional, default = false
The number of seconds before which this page expires and must
be 're-read' from the server. This value is only used if the 'cache' parameter
is set to 'true'. It is used for both the 'expires' header and the Cache-Control
'Max-Age' directive.
|
Results
The 'cache' method returns no useful information.
Remarks Browsers and intermediate devices can create and store local copies of
content from web servers and then deliver this version to browsers without
having to load the origin server. Usually his behaviour is beneficial and can reduce load on the origin server
and decrease page load times and latency of requests. Where the content is dynamic though it's important that the browser always
load data from the origin server. HTTP defines a set of headers that
allow the origin server to instruct intermediate devices and browsers whether they
may keep local copies of requests and for how long those copies may be used. Whitebeam can generate these headers on behalf of applications. The rb:cachecontrol hedader
and this method both allow the application to define caching policy for the current
request. Alternatively the application can request that Whitebeam generate no cache control
headers and take control of them itself. Calling rb.page.cache() with no parameters switches off Whitebeams
internal cache header logic. Alternatively parameters this call can tell Whitebeam what values to
place in the headers. There are two main uses of the Presentation Engine in server side
applications: - to generate dynamic page content from the
information available from the templates.
- to construct client side pages from static server-side
content - possibly by reformatting some existing data.
Examples of the latter include the processing of existing XML documents
to produce HTML and the use of 'include' files to define a sites look and
feel The second of these uses generates basically static client side
content that can take significant resource on the server end to create.
and potentially use network bandwidth unnecessarily. It is far better in
these cases to allow the intermediate devices and the browsers to cache
these pages. By default the Presentation Engine instructs network devices
to not cache the output from any Pattern Pages. This is always
safe - but potentially inefficient. This method provides a mechanism whereby a Web Author can enable page
caching - on a per page basis. The page will be capable of being cached by
calling this method with a parameter of 'true'. A further refinement of this allows the page to specify that the content - although
static - is logically only available to specific users. This means the output
contains data targetted at a specific user. It is necessary to prevent
such a page being cached and send to other users - while at the same time
allowing that users page to cache the datat. You do this by setting the
'max-age' parameter. |