如何在 wordpress 网页上停止图像缓存
How to stop image caching on a wordpress webpage
我在服务器上有一个名为 webcam.jpg 的图像。该图像每 2 分钟被一个同名的新图像替换。
我有一个 WordPress 页面来显示此图片。
问题是这张图片缓存在浏览器中,所以显示的是旧照片。如果我清除缓存,它就会开始显示当时的最新图像。
我尝试了以下方法 none 对我有用。
<img class="weather-cam-box alignleft" src="/cameraimages/webcam.jpg?2020" alt="" width="100%" height="764" />
<img class="weather-cam-box alignleft" src="/cameraimages/webcam.jpg?2020" alt="" width="100%" height="764" />
<img class="weather-cam-box alignleft" src="/cameraimages/webcam.jpg?342038402" alt="" width="100%" height="764" />
另外,我尝试定位到这个特定的页面,而不是使用下面的代码缓存该页面上的内容,但它也没有帮助。
<?php if ( is_page(22683) ) {?>
<?php nocache_headers(); ?>
<meta http-equiv="cache-control" content="no-cache" />
<?php } ?>
您可以尝试以下步骤。
You aren't adding the query string variable. Add variable and unique random number with the timestamp.
<img src="/cameraimages/webcam.jpg?nocache=<?php echo time(); ?>">
Add following meta tag to the head
<meta Http-Equiv="Cache-Control" Content="no-cache">
<meta Http-Equiv="Pragma" Content="no-cache">
<meta Http-Equiv="Expires" Content="0">
<meta Http-Equiv="Pragma-directive: no-cache">
<meta Http-Equiv="Cache-directive: no-cache">
我在服务器上有一个名为 webcam.jpg 的图像。该图像每 2 分钟被一个同名的新图像替换。 我有一个 WordPress 页面来显示此图片。
问题是这张图片缓存在浏览器中,所以显示的是旧照片。如果我清除缓存,它就会开始显示当时的最新图像。
我尝试了以下方法 none 对我有用。
<img class="weather-cam-box alignleft" src="/cameraimages/webcam.jpg?2020" alt="" width="100%" height="764" />
<img class="weather-cam-box alignleft" src="/cameraimages/webcam.jpg?2020" alt="" width="100%" height="764" />
<img class="weather-cam-box alignleft" src="/cameraimages/webcam.jpg?342038402" alt="" width="100%" height="764" />
另外,我尝试定位到这个特定的页面,而不是使用下面的代码缓存该页面上的内容,但它也没有帮助。
<?php if ( is_page(22683) ) {?>
<?php nocache_headers(); ?>
<meta http-equiv="cache-control" content="no-cache" />
<?php } ?>
您可以尝试以下步骤。
You aren't adding the query string variable. Add variable and unique random number with the timestamp.
<img src="/cameraimages/webcam.jpg?nocache=<?php echo time(); ?>">
Add following meta tag to the head
<meta Http-Equiv="Cache-Control" Content="no-cache">
<meta Http-Equiv="Pragma" Content="no-cache">
<meta Http-Equiv="Expires" Content="0">
<meta Http-Equiv="Pragma-directive: no-cache">
<meta Http-Equiv="Cache-directive: no-cache">