Using HTTP headers
VoiceXML 2.0 explicitly mandates the minimum support of the Cache-Control and Expires header fields. The Expires header indicates a date for when the object is to be considered no longer fresh. The Cache-Control: max-age header indicates that the object is stale after max-age seconds.. For example, listing 2 above indicates that index.html should be considered stale after 24 hours.
When an object expires, it must not be used unless it has been revalidated. There are two main ways of doing this. HTTP 1.0 and HTTP 1.1 use an efficient method that performs conditional fetches. A request for an object can be made supplying the If-Modified-Since header and an associated date. Assuming no errors, the origin server will return either a 304 status code indicating that the object has not modified and the cached version is the latest or a 200 status code followed by the new version of the object (similar to the response listing 2) if the object has changed. The second method (HTTP 1.1 only) uses a unique identifier called an Entity Tag or ETag to uniquely identify an object. An If-None-Match request header followed by the ETag (obtained in a previous response) indicates that the origin server should (assuming no errors) return a 304 not modified if the server's current ETag for the requested document matches the requested ETag or a 200 response followed by the new document if they do not.
If a document specifies Cache-Control: no-cache or Pragma: no-cache, the user agent will not cache the document and is useful for dynamic content that changes unpredictably.
If none of Expires, Cache-Control, Pragma, or ETag appears in the response, a cache may use the Last-Modified date to calculate an expiration time. This is called heuristic caching and formulas usually work on the basis of choosing an expiration time based on a fraction of the interval since the object was last modified. Since heuristic caching might cause problems with dynamic content generation mechanisms such as JSPs or ASPs etc, these mechanisms typically omit the Last-Modified date and are not cached.
Setting HTTP header fields in responses are specific to the server-side technology used. Typically, however, setting the headers is straightforward. Listing 3 illustrates setting a header for a JavaServer Page (JSP).
Listing 3: Setting a HTTP head in a JavaServer Page
Using VoiceXML attributes
VoiceXML 1.0 and VoiceXML 2.0 have slightly different mechanisms for controlling caching policy and we will mention both here. In VoiceXML 1.0, an attribute called caching is specified on elements requiring resources to be fetched (e.g.