Get request cache problem under IE browser

Source: Internet
Author: User

1 using GET Request data

1) Java Code $.getjson ("Sortshow!sortshow?time=" +new Date (). GetTime (), function () {}); At first I wrote the Java code directly, $.getjson (" Sortshow!sortshow,function () {}), so when the refresh of IE will show the last cache, so you have to submit new data, so after adding a time parameter, even if you do not set this parameter in the background, but will not error.
At this point, IE will re-send a request to the background, similar to the Math.random function can be used.
2) Set Cache:false property to prevent IE cache

2 use post to request data, can prevent IE cache

3 in doing Ajax page without refreshing add, ie under the AJAX cache, because at first did not know that IE has this bad problem, toss for a long time, finally solve the problem. To summarize the solution: in the IE under the AJAX request a page, usually because of the cache for the reason of returning the last result, causing confusion,
That is, get the data, because the sending parameters and address are consistent, so IE browser will be taken from the cache, not to request the server side,
The Post method does not produce this problem because of the parameters, but this does not happen under FF. In order to be unaffected by the cache, you can do this: IE Access policy: Internet Options--browsing history--settings--Options for temporary Internet files are changed every time you visit a webpage
After adding a random function to the page after the AJAX request, we can use the random time function to add t=math.random () to the URL that is sent by JavaScript, for example:
url+ "&" + "t=" +math.random ();//or New Date (); After the URL parameter, add "? timestamp=" + New Date (). GetTime (); The best way: $.ajaxsetup ({cache:false}) performs this when all AJAX requests are in the page. You don't have to change the N interfaces that have already been completed

Get request cache problem under IE browser

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.