【问题标题】:website update clear cache on all client side devices so img and content update网站更新清除所有客户端设备上的缓存,以便更新图像和内容
【发布时间】:2020-06-30 08:59:34
【问题描述】:
我是一名初学者 Web 开发人员,我需要帮助,因为我的网页 img 更新不会在客户端设备上自动刷新。我尝试将 ?v=1 添加到 img src 和 css。不工作。尝试在 css 中完整托管 img url。不更新。
有没有办法清除 pc 和移动设备的缓存,以便在添加内容和更改背景 img 时我的页面随处更新。
head...
<!--custom stylesheet-->
<link rel="stylesheet" type="text/css" href="css/style.css?v=1">
<link rel="stylesheet" type="text/css" href="css/main.css?v=1" />
body...
<img src="img/logo.webp?v=1" alt="logo" />
stylesheet...
background: url(../img/landing/body2.webp?v=1);
【问题讨论】:
标签:
image
web-hosting
blogs
browser-cache
wep
【解决方案1】:
我想通了,我正在编辑 img 文件并保存为原始文件名。这导致客户端图像出现问题。所以我重命名了我的 img 并添加了一个日期时间戳作为 ?v=(current date)。我在 html body 和 head css 中的 img、url、src 以及我编辑的任何地方都添加了日期时间戳。
head...
<!--custom stylesheet-->
<link rel="stylesheet" type="text/css" href="css/style.css?v=30Jun2020125632">
<link rel="stylesheet" type="text/css" href="css/main.css?v=30Jun2020125632" />
body...
<img src="img/logos.webp?v=30Jun2020125632" alt="logo" />
stylesheet...
background: url(../img/landing/body2.webp?v=30Jun2020125632);