简体   繁体   English

如何强制在JSP(即不是PHP)上重新加载缓存的css文件?

[英]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.

相关问题 如何在 setState 之后在 React 中强制立即更新 DOM(即提交)? - How can I force an immediate DOM update (i.e. commit) in React after setState? 强制IE中的链接在Firefox中打开 - Force a link in I.E. to open in Firefox CKEditor:编辑模板(例如PHP,JSP,ASP等…,即非标准HTML) - CKEditor: Editing templates (e.g. PHP, JSP, ASP, … i.e. non-standard HTML) 如何动态更新我的CSS,即我想让用户选择字体大小,bckground颜色 - How can I dynamically update my CSS i.e. I want to give user an option of selecting font size, bckground color 如何强制jQuery UI Selectmenu出现在jQuery模式窗口的上方(即前面)? - How do I force jQuery UI Selectmenu to appear above (i.e. in front of) a jQuery modal window? 强制JSON.stringify转义正斜杠(即`\ /`) - Force JSON.stringify to escape forward slash (i.e. `\/`) 我如何在反应中一起使用引导程序和自定义 css,即 home.module.css? - How do i use bootstrap and custom css i.e. home.module.css together in react? 如何根据浏览器(即Blackberry 8300)在网页上强制禁用JavaScript? - How to force JavaScript as disabled on a webpage depending on browser (i.e. on Blackberry 8300)? 我应该如何在流星项目中加载外部文件(即js,css,html)? - How should i load external files(i.e. js,css,html) in meteor project? Rails中有两个文件扩展名(即:.css.scss)有什么作用? - What does having two file extensions do in Rails (i.e.: .css.scss)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM