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

How to clear cache in javascript

coldplay.xixi
Release: 2023-01-04 09:35:42
Original
8589 people have browsed it

How to clear the cache in javascript: 1. Add relevant code in the head area of ​​html; 2. Clear the temporary cache; 3. Set the attribute [cache:false] through [$.ajaxSetup].

How to clear cache in javascript

The operating environment of this tutorial: Windows 7 system, JavaScript version 1.8.5, DELL G3 computer.

How to clear cache in javascript:

1, add code in the head area of ​​html:

<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="content-type" content="no-cache, must-revalidate" />
<meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT"/>
Copy after login

2, clear temporary cache

<body onLoad="javascript:document.yourFormName.reset()">
Copy after login

3. Two ways to clear the browser cache with jquery ajax:

1) Set the attribute cache:false through $.ajaxSetup to prevent ajax from calling the browsing cache.

jQuery.ajaxSetup ({cache:false})
Copy after login

2), add a random string after the ajax URL to avoid browsing cache, for example: $.ajax({url:'test.php?' parseInt(Math.random()*100000)} )cache.

Related free learning recommendations: javascript learning tutorial

The above is the detailed content of How to clear cache in javascript. 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