0

之前有人问过这个问题,但所提供的解决方案都不适合我。我只需要重新加载一个从服务器获取图像的页面,而不是缓存,因为同名的图像会发生变化。如果我使用 Chrome 插件清除缓存,它可以完成这项工作,但我需要以编程方式完成。我的代码是:-

<?php

$testid = $_COOKIE['s_testid'];
$testimg = 'tests/'.$testid.'_puzzle.png';

?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="cache-control" content="no-cache"> <!-- tells browser not to cache -->
<meta http-equiv="expires" content="0"> <!-- says that the cache expires 'now' -->
<meta http-equiv="pragma" content="no-cache"> <!-- says not to use cached stuff, if there is any -->
<title>Puzzle Check</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">

     function next() {    
      window.open('clt_inst_puzzle.php','_self');
     }
     
     function recheck() {
        //window.open('puzzle_check.php','_self');
        window.location.replace("puzzle_check.php");
     }
    
</script>

</head>
<body>
<form method="post" accept-charset="utf-8" name="form1">

<div id="test" style="position:absolute;visibility:visible;top:1px;left:1px;height:929px;width:700px;background-image: url(<?php echo $testimg; ?>); ?>;border-width:thin thin thin thin; border-color:#000; border-style:solid;"> </div>

<div id="lines" style="position:absolute;visibility:visible;top:1px;left:1px;height:929px;width:700px;background-image:url(../images/puzzle_lines.png); ?>;border-width:thin thin thin thin; border-color:#000; border-style:solid;"> </div>

<div id="instructions" style="position:absolute;visibility:visible;top:940px;left:20px;">
    <input type="button" align="left" name="bnext" id="bnext" value="Back to Instructions" onClick="next()">
        
    <input type="button" align="right" name="brecheck" id="brecheck" value="Re-check" onClick="recheck()">
</div>        
</form>
</body>
</html>

<meta 标签不起作用,也不行

caches.open('v1').then(function(cache) {
  cache.delete('/images/image.png').then(function(response) {
    someUIUpdateFunction();
  });
})

或者

location.reload(true) // deprecated

我应该做什么或我做错了什么?

4

0 回答 0