Page JS Cache problem Solution

Source: Internet
Author: User
Tags browser cache

1. Adding headers to the JSP<meta http-equiv="Pragma"Content="No-cache"> <meta http-equiv="Cache-control"Content="No-cache"> <meta http-equiv="Expires"Content="0">or Join<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"/>Clear Temporary Cache<body onload="Javascript:document.yourFormName.reset ()">2. In action, use the following declaration Response.setheader ("Pragma","No-cache"); Response.setheader ("Cache-control","No-cache"); Response.setdateheader ("Expires",0);3. Random Parameter document.write ("<script src= ' test.js?rnd="+math.random () +"' ></s"+"cript>"). 4. jquery Ajax clears the browser cache in two ways:1. Set properties via $.ajaxsetup cache:false, so that Ajax does not invoke the browse cache. Jquery.ajaxsetup ({cache:false}) 2You can avoid browsing the cache by adding a random string to the Ajax URL, such as $.ajax ({URL:'test.php?'+parseint (Math.random () *100000)}) cache5Sometimes the above method clears the cache only once, and the second time there is no effect. Therefore, I think the best way is, in the process of debugging, disable IE cache, so debugging is OK. However, the user will not be banned, this is not a problem? Users will not we do not care, if you write the JS code, we will add a version of the JS file number on the good. For example:<script type="Text/javascript"Src="<%=baseurl%>/xhd_js/select-ajax.js?1.0"></script>but what if the developer modifies the JS file user? After the modifications are determined to be used, add<script type="Text/javascript"Src="<%=baseurl%>/xhd_js/select-ajax.js?2.0"></script>You can resolve the issue. 

Page JS Cache problem Solution

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.