我在带有PrimeFaces5.3和OmniFaces2.3的JSF2.2项目中有字体文件,并且需要将这些文本字体文件(如.woff和.woff2)放在通配符缓存中,但不幸的是,我没有得到。
图像文件(.gif、.png)和CSS文件在缓存中,只有不在缓存中的文本字体。
我使用了这个站点的提示,但仍然无法使它工作:https://gist.github.com/remibantos/5e86829e1ba6ad64eea1
我将这些谓词放在通配符:... path-suffix [ '.woff2'] or path-suffix [ '.woff2.xhtml'],中,但无法获得缓存。
遵循用于执行缓存的代码WildFly 10:
standalone-full.xml
<subsystem xmlns="urn:jboss:domain:undertow:3.0">
<server name="default-server">
<host name="default-host" alias="localhost">
<filter-ref name="custom-max-age" predicate="path-suffix['.js'] or path-suffix ['.js.xhtml'] or path-suffix ['.json'] or path-suffix ['.json.xhtml'] or path-suffix ['.html'] or path-suffix ['.css'] or path-suffix ['.css.xhtml'] or path-suffix ['.jpg'] or path-suffix ['.jpg.xhtml'] or path-suffix ['.jpeg'] or path-suffix ['.jpeg.xhtml'] or path-suffix ['.png'] or path-suffix ['.png.xhtml'] or path-suffix ['.gif'] or path-suffix ['.gif.xhtml'] or path-suffix ['.eot'] or path-suffix ['.eot.xhtml'] or path-suffix ['.ttf'] or path-suffix ['.ttf.xhtml'] or path-suffix ['.woff'] or path-suffix ['.woff.xhtml'] or path-suffix ['.woff2'] or path-suffix ['.woff2.xhtml']"/>
</host>
</server>
<filters>
<response-header name="custom-max-age" header-name="Cache-Control" header-value="max-age=64800000, public"/>
</filters>
</subsystem>请帮我解决这个问题。
谢谢。
发布于 2016-08-23 23:58:52
经过一些测试后,我发现问题在于我没有使用ssl。如果我启用ssl (https),通常会发生缓存。
然后,在网站开发期间,我使用http,当我需要对缓存进行实验时,我使用https。
我不知道为什么会这样,但至少想出了解决这个问题和继续发展的办法。
衷心感谢您的帮助:)
发布于 2016-09-01 11:11:06
如果添加禁用缓存以保护页面=“false”,我认为它也将适用于非https。
<servlet-container name="default" disable-caching-for-secured-pages="false">https://stackoverflow.com/questions/37062704
复制相似问题