How to set up mod expires for fonts

user3796291 picture user3796291 · Jul 3, 2016 · Viewed 8k times · Source

I'd like to set expiry date for fonts. Following definition isn't working on apache 2.2.15.

ExpiresByType application/x-font-woff       "access plus 1 month"
ExpiresByType application/font-woff2         "access plus 1 month"

Answer

Danila Vershinin picture Danila Vershinin · Jul 3, 2016

First, add proper MIME types definitions:

AddType application/font-sfnt            otf ttf
AddType application/font-woff            woff
AddType application/font-woff2           woff2
AddType application/vnd.ms-fontobject    eot

Next, change your configuration lines to:

ExpiresByType application/font-woff "access plus 1 month" 
ExpiresByType application/font-woff2 "access plus 1 month"
ExpiresByType application/font-sfnt "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"