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?
Came up with a solution:
Use Apache’s
AddTypedeclaration to add a custom mime type and then use that mime type in theAddOutputFilterByTypedeclaration.For example, for opentype and truetype fonts:
Both these declarations require their appropriate modules to be active:
mod_mimeandmod_deflate. And for best practice, theAddTypedeclaration should be in the mime.conf file, and theAddOutputFilterByTypedeclaration should be in the deflate.conf file. See your particular distribution’s help files for enabling and configuring Apache modules.