The HDML language provides a TTL deck option, which allows you to specify how long an UP.Phone caches a deck. This option is described in Improving performance by modifying phone caching. However, in many cases, the TTL option does not provide enough control over how time-sensitive decks are cached. In particular, if a user backs up to a cached deck, the UP.Phone does not reload it, even if its TTL has expired.
The UP.Link platform allows HDML services to perform cache operations to invalidate stale information in a subscriber's UP.Phone. For example, if you know that an UP.Phone's cache contains a number of stock quotes that are out of date, you can use cache operations to invalidate the URLs that provide the quotes. This effectively removes the contents of the URLs from the cache, so that the next time the user navigates to them, the UP.Phone must request them again.
If you think a user is likely to navigate to a deck that you are invalidating, you can include the cache operation that invalidates the deck and a replacement deck in the same digest. That way, when the user navigates back to the deck, the replacement deck is already in the UP.Phone, so the UP.Phone doesn't need to request it from the UP.Link server. Optionally, you can invalidate all the decks from your service with a single cache operation.
A common way to execute cache operations is to send them asynchronously. This is an efficient way to update timely information "behind the scenes," without explicit user intervention. For more information on this process, see How HDML services can use notifications.
The UP.SDK libraries provide functions that allow you execute cache operations: the C function DigestAddCacheOp() and the Perl digest method addCacheOp(). Both functions allow you to invalidate individual decks or all the decks for a service. For specific information on these functions, see the UP.SDK Tools and APIs Reference.
Suppose your service provides an HDML deck containing a stock quote. The relative URL of the deck containing the quote is:
To invalidate this deck and force the UP.Phone to reload it the next time the user navigates to it, you could create a digest and add the cache operation to it as follows:
examples/source/digests */
main ()To generate the same cache operation using the UP.SDK Perl libraries, you would use code similar to the following: