Browser Support for Caching

Unfortunately, support for caching headers (or indeed many headers at all) is very poor in WAP browsers at the time of this writing. This means that pages may be cached even when you specifically request them not to be. To get around this, many sites insert a random number into the URL and set up the server to ignore this. Because the number changes from request to request, the browser treats each repeated request as if it were a new request.

For example, suppose there’s some information that changes regularly at the URL:

/news/headlines.wml

You can add a header that prevents the page from being cached at all, using the http-equiv form of the <meta> element in WML:

<meta http-equiv="Cache-Control" value="no-cache"/>

However, the browser may well ignore these header. To get around this, make the browser add a randomly chosen number to the URL requesting the page:

/news/headlines.wml?9832077283

Set up your web server to ignore this number and just serve the same page, and your caching problems go away. (The Apache web server does this by default.)

Get Learning WML, and WMLScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.