如何prevent CSS缓存网页上? [英] How to prevent CSS caching on a web page?

查看:157
本文介绍了如何prevent CSS缓存网页上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我学习开发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">

这篇关于如何prevent CSS缓存网页上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆