Home > Web Front-end > JS Tutorial > body text

How to clear cache in Ajax

php中世界最好的语言
Release: 2018-04-03 09:51:37
Original
2642 people have browsed it

This time I will show you how to clear the cache in Ajax, and what are the notes for clearing the cache in Ajax. The following is a practical case, let's take a look.

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.

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

ajax operation layer occlusion page

Use Ajax to add OA accounts based on human resources system data Methods

The above is the detailed content of How to clear cache in Ajax. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!