1
votes

I set up this code in .htaccess file but woff font doesn't cache.

<IfModule mod_expires.c>

ExpiresActive on
ExpiresDefault "access plus 1 month"
# Web fonts

AddType application/x-font-ttf ttc ttf
AddType application/x-font-woff .woff
AddType application/font-woff2 .woff2
AddType image/svg+xml .svg
AddType application/vnd.ms-fontobject eot

# Embedded OpenType (EOT)
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType font/eot "access plus 1 month"

# OpenType
ExpiresByType font/opentype "access plus 1 month"

# TrueType
ExpiresByType application/x-font-ttf "access plus 1 month"

# Web Open Font Format (WOFF) 1.0
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
ExpiresByType font/woff "access plus 1 month"

# Web Open Font Format (WOFF) 2.0
ExpiresByType application/font-woff2 "access plus 1 month"
</IfModule>

Response Header

Accept-Ranges: bytes
Content-Length: 2416
Content-Type: application/font-woff
Date: Sun, 23 Jun 2019 05:39:21 GMT
Last-Modified: Mon, 05 Nov 2018 15:58:57 GMT
Server: Apache/2.4.18 (Ubuntu)

I've also tried without ExpiresActive on and ExpiresDefault "access plus 1 month" but still not working again. What's the problem? How can I cache this kind of font? Other objects such as CSS, JS and all images cached properly by Cache-Control method but I still unable to cache woff fonts.

2

2 Answers

5
votes

Fixed the problem by this code:

<filesMatch ".(jpg|jpeg|png|gif|ico|svg|ttf|eot|woff|woff2)$">
Header set Cache-Control "max-age=31536000, public"
</filesMatch>
0
votes

Is the htaccess read at all? Place some gibberish in the first line and check if the server responds with a 500 error.