Home  >  Article  >  Web Front-end  >  How to clear cache in javascript

How to clear cache in javascript

coldplay.xixi
coldplay.xixiOriginal
2021-04-09 14:41:368574browse

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"/>

2, clear temporary cache

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

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})

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!

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