[英]How can I force a cached css file to be reloaded on a JSP (i.e. not PHP)?
I am altering a css file which will make drastic changes to my site. 我正在改变一个css文件,这将对我的网站进行大幅改动。 Is there a way to force the clients to reload the css so that they pick up the new changes.
有没有办法强制客户端重新加载css,以便他们获取新的更改。 Unfortunately asking thousands of people to CTRL + F5 or clear their cache isn't an option.
不幸的是,要求数千人使用CTRL + F5或清除缓存不是一种选择。 I read on a couple of blogs about appending todays date on the css filename as a parameter would work.
我在几个博客上读到有关在css文件名中附加今天日期的信息,因为参数可以正常工作。
You can add a unique query string parameter on to the end of the css file url 您可以在css文件URL的末尾添加唯一的查询字符串参数
<link rel="stylesheet" type="text/css" href="/my/css/file.css?123" />
Just increment the number each time you make an update. 只需在每次更新时增加数字。
EDIT: 编辑:
To load it from the web.xml file use the following: 要从web.xml文件加载它,请使用以下命令:
<link rel="stylesheet" type="text/css" href="/my/css/file.css?<%=application.getInitParamer("cssBuildNumber")%>" />
and this in web.xml 这在web.xml中
<context-param>
<param-name>cssBuildNumber</param-name>
<param-value>123</param-value>
</context-param>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.