Home  >  Article  >  Backend Development  >  5 ways to solve cache problems with Ajax

5 ways to solve cache problems with Ajax

小云云
小云云Original
2018-01-08 17:09:051387browse

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

Ajax cache processing

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn