Setting expire headers for fonts not working

I am using the below code in my .htaccess file to try and set the expire headers for some fonts, but upon checking my firefox cache and checking the expire header it the font is set to expire in about 12 hours from now; not the 1 year I am trying to set it to.

Here is my code:

# Add correct content-type for fonts
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf .ttf
AddType application/x-font-opentype .otf
AddType application/x-font-woff .woff
AddType image/svg+xml .svg

# Compress compressible fonts
AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-opentype image/svg+xml

# Add a far future Expires header for fonts
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType application/x-font-opentype "access plus 1 year"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"

What am I doing wrong?


Seems I had to include this bit as well:

ExpiresActive on

With the full code being:

# Add correct content-type for fonts
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf .ttf
AddType application/x-font-opentype .otf
AddType application/x-font-woff .woff
AddType image/svg+xml .svg

# Compress compressible fonts
AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-opentype image/svg+xml

ExpiresActive on

# Add a far future Expires header for fonts
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType application/x-font-opentype "access plus 1 year"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"

我相信你的问题是你如何定义字体,并且不需要添加他们的内容类型

 ExpiresByType font/truetype "access plus 1 year"
 ExpiresByType font/opentype "access plus 1 year"
 ExpiresByType application/x-font-woff   "access plus 1 year"
 ExpiresByType image/svg+xml "access plus 1 year"
 ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
链接地址: http://www.djcxy.com/p/46984.html

上一篇: 图标字体不在IE11中加载

下一篇: 设置字体无效的过期标题