JavaScript implementation automatically refreshes once the page is loaded and clears the cache file

Source: Internet
Author: User

We sometimes load the page, there will be a cache file on the performance of the current file is disturbed, such as some cached style files will be the page effect changes, then we want the page to be loaded with the automatic refresh of the cache file.

However, since the jump page will definitely use the content of the window object in the BOM section to change the current window, it is almost impossible to control the window's load count, since each new window produces all variables and object contents will be erased. At this time you can consider whether you can get the page jump load when the original page came from different information and make judgments to control the window is to continue to jump or stop jump. At this point, you can use the Window.location.search property.

Location.search can get the original page from the parameter information, the specific code control is actually very simple, my original page is demo.html, the following code:

<script>    if (window.location.search.indexOf ("?") <0) {//Determine if the first load        alert (window.location.search);        Window.location.href= "demo.html?1";    } else{}  //second load empty operation </script>

This is useful at some point, although it is extremely simple.

JavaScript implementation automatically refreshes once the page is loaded and clears the cache file

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.