2012-11-17 11 views
18

Ich verwende den folgenden Code in meiner. Htaccess-Datei zu versuchen, die Verfalls-Header für einige Schriftarten, aber nach Überprüfung meiner Firefox-Cache und Überprüfung der abgelaufenen Header ist die Schriftart festgelegt ablaufen in ungefähr 12 Stunden ab jetzt; nicht das 1 Jahr versuche ich es zu setzen.Einstellen verfallen Header für Schriftarten nicht funktioniert

Hier ist mein Code:

# 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 
AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-opentype image/svg+xml 

# 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" 

Was mache ich falsch?

+0

Stack Overflow ist eine Website für Programmier- und Entwicklungsfragen. Diese Frage scheint off-topic zu sein, weil es nicht um Programmierung oder Entwicklung geht. Siehe [Welche Themen kann ich hier fragen?] (Http://stackoverflow.com/help/on-topic) in der Hilfe. Vielleicht [Web Applications Stack Exchange] (http://webapps.stackexchange.com/), [Webmaster Stack Exchange] (http://webmasters.stackexchange.com/) oder [Unix & Linux Stack Exchange] (http: // unix.stackexchange.com/) wäre ein besserer Ort, um zu fragen. – jww

+0

@jww War das wirklich ein notwendiger Kommentar nach 5+ Jahren? Wenn du so besorgt über "on-topic" Fragen bist, solltest du vielleicht lieber neue Fragen trollern !? :) – Brett

+0

Das Problem ist, Leute sehen diese Frage und stellen dann ähnliche Fragen. Die einzige Möglichkeit, die Off-Topic-Ness zu signalisieren, die im Laufe der Zeit bestehen bleibt, ist die Custom-Close-Message. – jww

Antwort

57

Scheint ich auch dieses Bit umfassen musste hinzuzufügen:

ExpiresActive on 

Der vollständige Code lautet:

# 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 
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

Das funktionierte für mich auch. Was ist komisch, obwohl, dass ich einfach eine ExpiresDefault "Zugriff plus 1 Monat" hatte, die alle Dateitypen (HTML, JPG, CSS, JS, usw.) richtig _except_SVG behandelt. Nachdem ich ExpiresActive hinzugefügt hatte, funktionierte der ExpiresDefault auch für Svg. Irgendwelche Ideen, warum das wäre? –

+0

Schwer zu sagen, warum es für Sie ohne 'ExpiresActive' lief, aber seien Sie sicher, es immer in der Zukunft zu verwenden sicher. :) – Brett

0

Ich glaube, das Problem ist, wie Sie die Schriftarten definieren, und es gibt keine Notwendigkeit, ihre Content-Type

ExpiresByType font/truetype "access plus 1 year" 
ExpiresByType font/opentype "access plus 1 year" 
ExpiresByType application/x-font-woff "access plus 1 year" 
ExpiresByType image/svg+xml "access plus 1 year" 
ExpiresByType application/vnd.ms-fontobject "access plus 1 year" 
+0

Ich werde das versuchen, aber ich habe diese Definition von hier: http://stackoverflow.com/questions/2871655/proper-mime-type-for-fonts – Brett

+0

Ok, nur das getestet und es hat sich nichts geändert. :( – Brett

Verwandte Themen