This article mainly brings you a summary of 5 methods of Ajax caching (recommended). The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor to take a look, I hope it can help everyone.
1. Add anyAjaxObj.setRequestHeader(“If-Modified-Since”, “0″) before sending the ajax request.
2. Add anyAjaxObj.setRequestHeader(“Cache-Control”, “no-cache”) before sending the request via ajax.
3. Add a random number after the URL: “fresh=" + Math.random();.
4. Add the time after the URL: "nowtime=" + new Date().getTime();.
5. If you are using jQuery, just do $.ajaxSetup({cache:false}). In this way, all ajax on the page will execute this statement and there is no need to save cache records.
Related recommendations:
ajax2—solve cache problems—php (28)
Summary of solutions to Ajax cache problems
The above is the detailed content of 5 ways to solve cache problems with Ajax. For more information, please follow other related articles on the PHP Chinese website!