In the Js code, a random number is added after the ajax request address to prevent browser caching. Friends who need it can refer to
When you see JS written by others, random parameters are added after the ajax request address, such as XXXX ?t= new Date().getTime().
I didn’t understand why at first, so I checked the information online. The reason is to prevent browser caching.
In order to improve the speed of users accessing the same page, the browser will cache the page data. When the url request address remains unchanged,
sometimes causes the browser to not send the request and read the previous data directly from the cache.
If the data changes without adding random numbers, the data read will be the same as before.
Adding a random number is to trick the browser into changing the url, and it will send a request to the server every time without reading the cache.
The above is what I compiled for everyone. I hope it will be useful in the future. Everyone is helpful.
Related articles:
Json-lib processing solution when using frameworks such as Ajax or Easyui (graphic tutorial)
Ajax Realize the effect of infinite loading of lists and secondary drop-down options
Example sharing of using AJAX to implement progress bars on web pages
The above is the detailed content of Why add a random number after the ajax request address to prevent browser caching. For more information, please follow other related articles on the PHP Chinese website!