Summary of several methods of clearing browser cache by react+django

  • 2021-07-22 10:13:26
  • OfStack

1. meta method

Packed entrance index. html head added


<META HTTP-EQUIV="pragma" CONTENT="no-cache"> 
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate"> 
<META HTTP-EQUIV="expires" CONTENT="0">

2. Ways to clean up the form


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

In fact, form form cache is helpful for us to write, 1 general situation is not recommended to clean up, but sometimes for security issues, etc., need to clean up 1!

3. ajax method


$.ajax({
   url:'www.haorooms.com',
   dataType:'json',
   data:{},
   beforeSend :function(xmlHttp){ 
    xmlHttp.setRequestHeader("If-Modified-Since","0"); 
    xmlHttp.setRequestHeader("Cache-Control","no-cache");
   },
   success:function(response){
     // Operation 
   }
   async:false
 });

Or use cache: false directly


$.ajax({
   url:'www.haorooms.com',
   dataType:'json',
   data:{},
   cache:false, 
   ifModified :true ,
 
   success:function(response){
     // Operation 
   }
   async:false
 });

Related articles: