@font-face and Header set Access-Control-Allow-Ori

2019-03-01 13:18发布

问题:

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...