Following old advices here and here I'm curious what is the proper syntax for APACHE server:
AddType font/woff2 .woff2
ExpiresByType font/woff2 "access plus 1 year"
or
AddType application/woff2 .woff2
ExpiresByType application/woff2 "access plus 1 year"
CodePudding user response:
Did you include the ExpiresActive on
?
<IfModule mod_expires.c>
ExpiresActive On
AddType font/woff2 .woff2
ExpiresByType font/woff2 "access plus 1 year"
</IfModule>
I am using something like these:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType image/svg "access plus 2592000 seconds"
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
ExpiresByType text/css "access plus 2592000 seconds"
ExpiresByType text/javascript "access plus 2592000 seconds"
ExpiresByType application/x-javascript "access plus 2592000 seconds"
</IfModule>
CodePudding user response:
what is the proper syntax for APACHE server
It's not really a question of "syntax". Both your examples use the same "syntax". But rather, what is the correct/official mime-type (that user-agents understand).
The official mime-type according to the WOFF2 spec (W3C Recommendation / 1-March-2022) is:
font/woff2
This was initially discussed in the WOFF File Format 2.0 - W3C Working Draft 14 April 2015 - Appendix A: Internet Media Type Registration
AddType application/woff2 .woff2
I don't think application/woff2
has ever been a (proposed) mime-type? The IANA Media Types initially defined application/font-woff
for woff font files, so by extension you could assume that application/font-woff2
would be used for woff2, but I don't see this documented anywhere? And IANA have since "deprecated" application/font-woff
in favour of font/woff
and list only font/woff2
for woff2 font files.
AddType font/woff2 .woff2
You shouldn't need to manually add the AddType
directive here. Providing you are using a relatively recent distro of Apache then the mime.types
file that is imported (using the TypesConfig
directive) during startup already includes the necessary (and correct) mime-type for .woff2
files:
font/woff2 woff2
See also: