How can I implement CSS Cache Busting with JSF outputStylesheet?

强颜欢笑 提交于 2019-12-22 04:01:11

问题


In JSF page templates I use this code to include a CSS resource:

<h:outputStylesheet library="css" name="mystyles.css"  />

The usual way to implement CSS cache busting would be to add a version parameter, like v=123, however this is not supported in outputStyleSheet:

<h:outputStylesheet library="css" name="mystyles.css?v=123"  />

will cause a JSF1064 warning and the CSS will not be found.


回答1:


That's not possible without overridding the StylesheetRenderer (assuming you're on Mojarra). It does indeed not take the query string into account. However, as a (temporary) workaround it's good to know that it is valid to include the CSS using CSS' own @import rule inside <h:outputStyleSheet>.

<h:outputStylesheet target="head">
    @import url('css/mystyles.css?v=123')
</h:outputStylesheet>

You might want to post an enhancement request to the Mojarra boys to take this into account in future releases.



来源:https://stackoverflow.com/questions/6307814/how-can-i-implement-css-cache-busting-with-jsf-outputstylesheet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!