About JS Cache processing

Source: Internet
Author: User

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The client has an HTML file that is used to submit input information, and the problem is that each time you press refresh, it is not the entire page being reloaded, as if it were a cache.
How do I avoid this problem because the last input value still appears in the text box and is only reloaded in the Address bar when you press ENTER for the entire page?

1. Add code to the head area in HTML:

Copy Code code example: <meta http-equiv= "Pragma" content= "No-cache"/>
<meta http-equiv= "Content-type" content= "No-cache, must-revalidate"/>
<meta http-equiv= "Expires" Content= "Wed, 1997 08:21:57 GMT"/>

2, clear the temporary cache

Copy Code code example: <body onload= "Javascript:document.yourFormName.reset ()" >

3,jquery Ajax clears the browser cache in two ways:
1), set the property cache:false through $.ajaxsetup, so that Ajax does not invoke the browse cache.

Copy Code code example: Jquery.ajaxsetup ({cache:false})

2), add a random string to the Ajax URL to avoid browsing the cache, for example:$.ajax ({url: ' Test '). PHP? ' +parseint (Math.random () *100000)}) cache.

About JS Cache processing

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.