2014-10-24 8 views
14

In Pagespeed Insights Ich sehe immer wieder die Meldung Browser-Caching eines bestimmten iconset/font Ich verwende zu nutzen: iconFont.woff (2 Tage)Wie nutze ich das Browser-Caching von .woff-Fonts?

ich meine .htaccess gesetzt, wie so haben:

## EXPIRES CACHING ## 
<IfModule mod_expires.c> 
ExpiresActive On 
ExpiresByType font/ttf "access 1 week" 
ExpiresByType font/woff "access 1 week" 
ExpiresByType image/jpg "access 1 month" 
ExpiresByType image/jpeg "access 1 month" 
ExpiresByType image/gif "access 1 month" 
ExpiresByType image/png "access 1 month" 
ExpiresByType text/css "access 1 week" 
ExpiresByType application/pdf "access 1 month" 
ExpiresByType application/javascript "access 1 month" 
ExpiresByType application/x-shockwave-flash "access 1 month" 
ExpiresByType image/x-icon "access 1 year" 
ExpiresDefault "access 2 days" 
</IfModule> 
## EXPIRES CACHING ## 

Trotzdem bekomme ich immer noch die gleiche Nachricht in PageSpeed ​​Insights. Wie cache ich das richtig?

+1

Vielleicht font/woff funktioniert nicht, versuchen Sie dies: http://stackoverflow.com/questions/3594823/mime-type-for-woff-fonts?rq=1 –

Antwort

47

Dies macht die Arbeit für mich, da Google Seitengeschwindigkeit nicht mehr darum bittet, es zu beheben. Der AddType ist wichtig.

# Fonts 
# Add correct content-type for fonts 
AddType application/vnd.ms-fontobject .eot 
AddType application/x-font-ttf .ttf 
AddType application/x-font-opentype .otf 
AddType application/x-font-woff .woff 
AddType image/svg+xml .svg 

# Compress compressible fonts 
# only uncomment if you dont have compression turned on already. Otherwise it will cause all other filestypes not to get compressed 
# AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-opentype image/svg+xml 

ExpiresActive on 

# Add a far future Expires header for fonts 
ExpiresByType application/vnd.ms-fontobject "access plus 1 year" 
ExpiresByType application/x-font-ttf "access plus 1 year" 
ExpiresByType application/x-font-opentype "access plus 1 year" 
ExpiresByType application/x-font-woff "access plus 1 year" 
ExpiresByType image/svg+xml "access plus 1 year" 
+0

Dieser funktioniert der Trick. Sollte als korrekt markiert werden – autarq

+0

Hallo Ich habe versucht, dies in .htaccess hinzufügen, aber wenn ich die Website nach dem Hinzufügen dieser Website laden zeigte "500" internen Serverfehler ". –

+0

@NileshKumar Hinzufügen oben ExpiresActive auf und Nach der letzten Zeile wird der Fehler behoben –

Verwandte Themen