如何在开发中禁用CSS缓存,使用PHP后端?

发布于 2025-02-01 19:06:56 字数 203 浏览 4 评论 0原文

我正在通过Localhost从事PHP/CSS项目,几乎每次更改CSS和Reload页面时,CSS都保持不变,直到删除Cookie,Cache和其他站点数据(即使这样,它也无法立即工作)。 CSS可以正确地链接以及其他所有内容,因此这不是代码的问题,而是浏览器/缓存的问题。

我的问题是 - 除了每次更改CSS中的某些内容时删除cookie和缓存,是否有其他方法可以解决此问题?

I'm working on php/css project through localhost and nearly every time I change css and reload page, css remains unchenged until I delete cookies, cache and other site data (somethimes even then it doesn't work straight away). Css is linked correctly, as well as aeverything else, so this is not a problem with code, but with browser/cache.

My question is- is there a way to resolve this issue other than deleting cookies and cache every time I change something in my css?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

超可爱的懒熊 2025-02-08 19:06:57

请在CSS中添加查询参数,并修改了动态文件:

<link rel="stylesheet" href="style.css?v=<?php echo filemtime("style.css");?>" />

Please add a query parameter to CSS with dynamic file modified time:

<link rel="stylesheet" href="style.css?v=<?php echo filemtime("style.css");?>" />
那小子欠揍 2025-02-08 19:06:57

所有的评论和答案都是有帮助的,但是长期没有解决问题。

经过一些实验后,我找到了一个答案:在

Chrome设置中,禁用给定站点的cookie和Cache的缓存&gt;高级隐私与安全&GT;永远无法使用cookie的网站

All the comments and answers were helpful, but none of them solved the problem long term.

After some experimenting, I found an answer: disable saving cookies and cache for given site, in

chrome settings > advanced > Privacy and security > Sites that can never use cookies

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文