Work Pit record: JavaScript jump is cached

Source: Internet
Author: User

Cause: The business wants a fixed QR code to jump to different pages each week, I use JS to write a jump, but found to be cached, although the cache is not clear how long, but the cache is very uncomfortable, does not meet the business real-time change this QR code jump page needs.

After: Since the page is cached, then at the top of the page meta says do not cache chant, the head tag add the following code:

<meta http-equiv= "Pragma" content= "No-cache" >
<meta http-equiv= "Cache-control" content= "No-cache" >
<meta http-equiv= "Expires" content= "0" >

The result you understand, invalid! Very strange, "window.location.href=" Https://XXXXX ";" as soon as this code appears in the page, the jump is cached , and if this is removed, the HTML like alert and other pages will not be cached.

Solution: Just when I worry, think of the previous solution to the JS cache method, is to add a random number after the reference URL. This gives me an inspiration, since the browser caches the page's jump code, then I will do a page jump, and add this parameter, so that the loaded jump page will not be cached again. Can be used after testing.

PS: Although the HTML document is written in meta-settings can prevent page caching, but this is only a standard, how to implement or to see the browser's own, I am using the Chrome browser, it is estimated to "window.location.href=" Https://XXXXX ";" has been optimized, as long as this statement appears will cache the page (I guess). If you have more information about this problem, you are welcome to communicate.

Work Pit record: JavaScript jump is cached

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.