views:

630

answers:

1

I am using the @font-face CSS property to load a special font for headings on a website, and I want Apache to send the font compressed to reduce loading time.

However, the "AddOutputFilterByType" declaration in Apache 2's deflate module only accepts mime types and, as AFAIK, neither opentype nor truetype have registered mime types.

So, how do I configure Apache to deflate/compress font.otf or font.ttf files?

+5  A: 

Came up with a solution:

Use Apache's AddType declaration to add a custom mime type and then use that mime type in the AddOutputFilterByType declaration.

For example, for opentype and truetype fonts:

Addtype font/opentype .otf
Addtype font/truetype .ttf
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css font/opentype font/truetype

Both these declarations require their appropriate modules to be active: mod_mime and mod_deflate. And for best practice, the AddType declaration should be in the mime.conf file, and the AddOutputFilterByType declaration should be in the deflate.conf file. See your particular distribution's help files for enabling and configuring Apache modules.

Torrance