首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在野蝇10中缓存字体(.woff,woff2,.ttf,.eot)?

如何在野蝇10中缓存字体(.woff,woff2,.ttf,.eot)?
EN

Stack Overflow用户
提问于 2016-05-06 01:13:32
回答 2查看 1.6K关注 0票数 3

我在带有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

代码语言:javascript
复制
    <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>

请帮我解决这个问题。

谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-08-23 23:58:52

经过一些测试后,我发现问题在于我没有使用ssl。如果我启用ssl (https),通常会发生缓存。

然后,在网站开发期间,我使用http,当我需要对缓存进行实验时,我使用https。

我不知道为什么会这样,但至少想出了解决这个问题和继续发展的办法。

衷心感谢您的帮助:)

票数 0
EN

Stack Overflow用户

发布于 2016-09-01 11:11:06

如果添加禁用缓存以保护页面=“false”,我认为它也将适用于非https。

代码语言:javascript
复制
<servlet-container name="default" disable-caching-for-secured-pages="false">
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37062704

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档