@font-face and Header set Access-Control-Allow-Origin “*”

会有一股神秘感。 提交于 2019-12-20 04:51:22

问题


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?


回答1:


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

Header set always Access-Con...


来源:https://stackoverflow.com/questions/3619779/font-face-and-header-set-access-control-allow-origin

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