How to prevent the reading of WML pages from cache

Source: Internet
Author: User
Tags header
cache| page when a WML page is downloaded to a WAP device, it is saved in the WAP device memory for a period of time until the time expires. After that, the page is downloaded from the server, not from the cache of the WAP device. This process is called cache.
But there are times when you don't want the page to read from the cache, but from the server side. A typical example is when the content of the server is constantly updated, by adding some cache information to the HTTP header to tell the WAP device that the page will not be stored in the cache.
You can generate HTTP headers on the server side, or use PHP, ASP, Perl, or other service-side development languages. This line cannot be included in the page, and since it is an HTTP header, it is not a WML element.
For static pages, the server-side scripting language may not be used, and many browsers support meta tags to control the cache of browsers. Look at the final example of this section.
Add the following code to the HTTP header, and the page will expire immediately:
Expires:mon, June June 1997 05:00:00 GMT
Last-modified:dd. Month YYYY HH:MM:SS GMT
Cache-control:no-cache, Must-revalidate
Pragma:no-cache
The first line tells the Mini browser that the page has expired for some time. The second line tells the browser when the page was last modified. DD should be replaced by day date, month YY HH MM SS, and so on. The third and fourth lines have the same effect. Tells the browser that the page is not cache (the third line applies to HTTP 1.1, and line fourth applies to HTTP 1.0).
The following is an example of PHP:
?
Set the correct MIME type
Header ("CONTENT-TYPE:TEXT/VND.WAP.WML");
Expires in the past
Header ("Expires:mon, June June 1997 05:00:00 GMT");
Last modified.
Header ("last-modified:"). Gmdate ("D, D M Y h:i:s"). "GMT");
Prevent caching, http/1.1
Header ("Cache-control:no-cache, must-revalidate");
Prevent caching, http/1.0
Header ("Pragma:no-cache");
?>
The following is an example of using WebClasses (VB). Use "Response.expires=-1" to prevent cache.
Private Sub Webclass_start ()
' Set correct MIME type
Response.ContentType = "TEXT/VND.WAP.WML"
     
' Make sure no caching
Response.Expires =-1
Response.AddHeader "Pragma", "No-cache"
Response.AddHeader "Cache-control", "No-cache, Must-revalidate"
   
' Use BASICWML (my own) as template
Set Nextitem = basicwml
End Sub
Here is an example of an ASP, using the same "response.expires=-1" to prevent cache.
<%
Response.ContentType = "TEXT/VND.WAP.WML"
Response.Expires =-1
Response.AddHeader "Pragma", "No-cache"
Response.AddHeader "Cache-control", "No-cache, Must-revalidate"
%>
Finally, use the meta example:
<?xml version= "1.0"?>
<! DOCTYPE WML public "-//wapforum//dtd WML 1.1//en"
"' Target=_blank> Http://www.wapforum.org/DTD/wml_1.1.xml ">
<wml>
<meta forua= "true" http-equiv= "Cache-control" content= "max-age=0"/>
<card id= "Alwaysexpire" >
<p>this deck would never be stored in the cache</p>
</card>
</wml>
The following page expires after 86,400 seconds (hours).
<?xml version= "1.0"?>
<! DOCTYPE WML public "-//wapforum//dtd WML 1.1//en"
"' Target=_blank> Http://www.wapforum.org/DTD/wml_1.1.xml ">
<wml>
<meta forua= "true" http-equiv= "Cache-control" content= "max-age=86400"/>
<card id= "Expire1day" >
<p>this card would live in the cache for a day</p>
</card>
</wml>
Some browsers such as: Up.simulator if you can get another card by "back", it will not reload the card. In order to force this update action, the user must use the Must-revalidate parameter in the META tag.
<meta forua= "true" http-equiv= "Cache-control" content= "Must-revalidate"/>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.