How to set up mod expires for fonts
Asked Answered
E

2

9

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"
Ennead answered 3/7, 2016 at 1:33 Comment(0)
A
25

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"
Actinolite answered 3/7, 2016 at 16:57 Comment(1)
If you're satisfied with the answer, mark it as correct :) thanks.Actinolite
T
3

I find it easier to use file extensions rather than mine types, especially as the Woff mime type changed a few times.

# Set up caching on font files for 6 months (60 * 60 * 24 * 180 = 15724800)
<filesMatch ".([eE][oO][tT]|[tT][tT][fF]|[sS][vV][gG]|[Ww][Oo][Ff][Ff]|[Ww][Oo][Ff][Ff]2)$">
   ExpiresDefault A15724800
   Header append Cache-Control "public"
</filesMatch>
Telemotor answered 3/7, 2016 at 16:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.