In JavaScript code, the random number is added after the ajax request address to prevent browser caching.

Source: Internet
Author: User

When someone else writes JavaScript code, add random parameters to the ajax request address, such as XXXX? T = + new Date (). getTime ().

At first, I couldn't understand why. I checked the information on the Internet because it prevented browser caching.

The browser caches page data to speed up user access to the same page. When the url request address remains unchanged,

Sometimes, the browser does not send a request and reads the previous data directly from the cache.

If the data changes without adding a random number, the read data will be the same as before.

When a random number is added, the browser url is changed and a request is sent to the server without reading the cache.

Related Article

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.