Blog
Woff and Caching
WOFF (Web Open Font Format) is a new web font format developed by Mozilla to embed custom fonts to websites. As I tried to use WOFF among with EOT (for Internet Explorer) and TrueType (Firefox 3.5) for this site, I noticed that Firefox is requesting the WOFF font twice and doesn't cache it, so it gets requested every time.
While debugging with Firebug I saw that Firefox aborts the first download of the font, request it again and then apply it to the website. This really turns down page loading.
I remembered having this issue with *.ttf and *.eot too and I fixed it before.
Lighttpd sends the *.woff as Content-Type: application/octet-stream by default. Firefox still applies the font, but it's not cached since it's an unknown Content-Type for him. The right Internet media type for WOFF files is application/x-woff.
Lighttpd in Debian uses a Perl script which parses /etc/mime.types (also default in Fedora) to make the MIME types known. Unfortunately Lighttpd does not allow adding a second mimetype.assign = () to your lighttd.conf.
So you'll need to add the following lines to /etc/mime.types:
application/vnd.bw-fontobject eot
application/x-font-ttf ttf
application/x-woff woff
Apache
Apache sends a file as text/plain if the file extension is unknown. Firefox is caching all plain text files, so you'll probably not encounter caching issues, but it's a good idea to add the right content types to your .htaccess file:
AddType application/vnd.bw-fontobject .eot
AddType application/x-font-ttf .ttf
AddType application/x-woff .woff
Posted under HTML+CSS, web fonts, web development, Lighttpd, Apache at August 10, 2010 4:37:00 PM CEST. 0 Comments were added. Permalink
