How to prevent WML pages from being read from the Cache

Source: Internet
Author: User
After the WML page is downloaded to the WAP device, it will be stored in the WAP device memory for a period of time until this time expires. After that, the page will be downloaded from the server, rather than from the cache of the WAP device. when the WML page is downloaded to the WAP device, it will be stored in the WAP device memory for a period of time, until this time expires. After that, the page will be downloaded from the server rather than from the cache of the WAP device. This process is called Cache.
However, sometimes the page is read from the server rather than from the cache. A typical example is to tell the WAP device that the page will not be stored in the cache by adding certain cache information to the HTTP header when the server content is constantly updated.
You can generate an HTTP header on the server, or use PHP, ASP, Perl, or other server development languages. This line cannot be included in the page. since it is an HTTP information header, it is not a WML element.
For static pages, the server script language may not be used. many browsers support META tags to control the browser Cache. Let's look at the final example in this section.
Add the following code to the HTTP header and the page will expire immediately:
Expires: Mon, 26 Jul 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 micro-browser that the page has expired for a while. The second line shows the last modification time of the browser page. DD should be replaced by the date of the day, month yy hh mm ss, and so on. The third row has the same effect as the fourth row. Tell the browser that the page is not cached (line 3 applies to HTTP 1.1 and line 4 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, 26 Jul 1997 05:00:00 GMT ");
// Last modified, right now
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 ASP example, which also uses "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, the example of using META is as follows:

"'Target = _ blank> http://www.wapforum.org/DTD/wml_1.1.xml">
 
   
     
   
   
     

This deck will never be stored in the cache


   
 
The following page expires after 86400 seconds (24 hours.

"'Target = _ blank> http://www.wapforum.org/DTD/wml_1.1.xml">
 
   
     
   
   
     

This card will live in the cache for a day


   
 
Some browsers, such as UP. Simulator, do not reload the card if they can reach another card through "return. To force this update, you must use the must-revalidate parameter in the META tag.

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.