如何prevent CSS缓存网页上?缓存、网页、prevent、CSS

2023-09-03 12:19:59 作者:芐雨天ジ誰心疼°

我学习开发XHTML,CSS网页。通常我做改变CSS,但它不会因为浏览器cacheing页面上体现,如果我手动清除cahceing它显示了最新的code的效果。有一件事我可以把code键使browker不缓存东西?任何意见,请

I am learning to develop xhtml, css web pages. Often I am doing changes in CSS but it do not reflect on page because of browser cacheing and if I manually clear cahceing it shows latest code effects. Is there a thing I can put in code to make browker not to cache stuff ? Any advice please

推荐答案

您可以(通过JavaScript或服务器端code为例)追加随机查询参数样式表的URL。 它不会改变正在加载CSS文件,但它会prevent缓存,因为浏览器检测到一个不同的URL,并不会加载缓存的样式表。

You can append a random query parameter to the stylesheet url (for example via javascript or server side code). It will not change the css file that is being loaded, but it will prevent caching, because the browser detects a different url and will not load the cached stylesheet.

<link rel="stylesheet" type="text/css" href="http://mysite/style.css?id=1234">