@font-face 和 Header 设置 Access-Control-Allow-Origin "*"

发布于 2024-09-17 05:55:22 字数 661 浏览 4 评论 0 原文

我使用了以下规则来允许我们的静态域托管字体,但是当启用浏览器缓存时,我遇到了浏览器(firefox、safari)不使用字体的问题。

<Directory "/site/http/web/assets/fonts">
    <FilesMatch "\.(eot|otf|woff|ttf)$">
        SetEnvIf Origin "^http://(.*)?main-domain.com$" origin_is=$0
        Header set Access-Control-Allow-Origin %{origin_is}e env=origin_is
    </FilesMatch>
</Directory>

我还使用以下规则让浏览器知道可以缓存静态内容:

ExpiresActive On
ExpiresDefault "modification plus 10 years"

如果我在浏览器缓存关闭的情况下浏览网站,则每次都会加载并显示字体。

如果我关闭浏览器缓存并加载页面,则会加载字体(firebug > net)但不会显示!

304 Content Not Modified 标头是否导致浏览器忽略我的努力?

I have used the following rule to allow our static domain to host fonts, but I've run into a problem font's not being used by the browser (firefox, safari) when the browser cache is enabled.

<Directory "/site/http/web/assets/fonts">
    <FilesMatch "\.(eot|otf|woff|ttf)$">
        SetEnvIf Origin "^http://(.*)?main-domain.com$" origin_is=$0
        Header set Access-Control-Allow-Origin %{origin_is}e env=origin_is
    </FilesMatch>
</Directory>

I've also used the below rule to let browsers know it's ok to cache static content:

ExpiresActive On
ExpiresDefault "modification plus 10 years"

If I browse the site with the browser cache off, the fonts load and display every time.

If I turn my browser cache off and load a page, the fonts get loaded (firebug > net) but aren't displayed!

Is the 304 Content Not Modified Header causing the browser to ignore my efforts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北斗星光 2024-09-24 05:55:22

如果您希望标头添加用于非 2xx 响应,请使用

Header set always Access-Con...

If you want your header addition to be used on a non-2xx response, use

Header set always Access-Con...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文