7

フォントの有効期限を設定したい。次の定義は では機能しませんapache 2.2.15

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

2 に答える 2

21

まず、適切な MIME タイプの定義を追加します。

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

次に、構成行を次のように変更します。

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"
于 2016-07-03T16:57:59.340 に答える
2

特にWoffの MIME タイプが数回変更されたため、私のタイプよりもファイル拡張子を使用する方が簡単だと思います。

# 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>
于 2016-07-03T16:46:21.410 に答える