How to clear the XMLHTTP cache. How to clear the cache of XMLHTTP

Source: Internet
Author: User

 

In the past few days, we need to test the webpage and use XMLHTTP to discover that IE directly calls the cache.

 

For online viewing, most of them are solved by adding page parameters, such as pageid = xxxxxx, but it is very troublesome for the root page, such as www.google.cn.

As shown in the following example, Google and csdn use the pageid and head methods. the other is setRequestHeader, which is implemented by setting the request header. I personally hate a situation where I ask other people's questions, and I don't want to take a bubble and put a fart in the end. I have solved this problem by myself. This kind of person is basically share killer, which is a kind of selfish, as long as it gets it, it will never be paid. too many things are said.

I hate this because XMLHTTP is just a tool, and we should not spend a lot of time studying how to use it "smartly, to obtain a very small problem, such as cache, browser vendors should give methods to this common problem, rather than letting us waste time studying their tools. this is a waste of time.

 

Solution: IE7 and webbrowser are valid. If you haven't tried any other solutions, you can post your comments. Thank you.

The following setRequestHeader is the best choice.

Source: http://www.jb51.net/article/12336.htm (should not be the final source)

// _ Oxmlhttp is an XMLHTTP object <br/> _ oxmlhttp. abort (); <br/> _ oxmlhttp. open ("get", _ strsite, true); <br/> _ oxmlhttp. setRequestHeader ("no-Cache", "1"); <br/> _ oxmlhttp. setRequestHeader ("Pragma", "No-Cache"); <br/> _ oxmlhttp. setRequestHeader ("cache-control", "No-Cache"); <br/> _ oxmlhttp. setRequestHeader ("expire", "0"); <br/> _ oxmlhttp. setRequestHeader ("last-modified", "wed, 1 Jan 1997 00:00:00 GMT"); <br/> _ oxmlhttp. setRequestHeader ("If-modified-since", "-1"); <br/> _ oxmlhttp. onreadystatechange = _ yourcallbackfn; <br/> _ oxmlhttp. send (); 

 

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.