@font-face 和 Header 设置 Access-Control-Allow-Origin "*"; [英] @font-face and Header set Access-Control-Allow-Origin "*"

查看:25
本文介绍了@font-face 和 Header 设置 Access-Control-Allow-Origin "*";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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

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

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

推荐答案

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

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

Header set always Access-Con...

这篇关于@font-face 和 Header 设置 Access-Control-Allow-Origin "*";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆