Setting expire headers for fonts not working

前端 未结 2 878
小蘑菇
小蘑菇 2020-12-13 14:09

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 the expire header, the font is set to

2条回答
  •  青春惊慌失措
    2020-12-13 15:07

    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 font/ttf .ttf
    AddType font/otf .otf
    AddType font/woff .woff
    AddType font/woff2 .woff2
    AddType image/svg+xml .svg
    
    # Compress compressible fonts
    AddOutputFilterByType DEFLATE font/ttf font/otf image/svg+xml
    
    ExpiresActive on
    
    # Add a far future Expires header for fonts
    ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
    ExpiresByType font/ttf "access plus 1 year"
    ExpiresByType font/otf "access plus 1 year"
    ExpiresByType font/woff "access plus 1 year"
    ExpiresByType font/woff2 "access plus 1 year"
    ExpiresByType image/svg+xml "access plus 1 year"
    

提交回复
热议问题