css - 压缩/缩小@font-face 字体

标签 css apache fonts font-face compression

我正在使用 @font-face CSS 属性加载网站标题的特殊字体,我希望 Apache 发送压缩字体以减少加载时间。

但是,Apache 2 的 deflate 模块中的“AddOutputFilterByType”声明只接受 mime 类型,据我所知,opentype 和 truetype 都没有注册 mime 类型。

那么,我该如何配置 Apache 来放气/压缩 font.otf 或 font.ttf 文件?

最佳答案

提出解决方案:

使用 Apache 的 AddType 声明添加自定义 MIME 类型,然后在 AddOutputFilterByType 声明中使用该 MIME 类型。

例如,对于 opentype 和 truetype 字体:

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

这两个声明都需要激活相应的模块:mod_mimemod_deflate。对于最佳实践,AddType 声明应该在 mime.conf 文件中,而 AddOutputFilterByType 声明应该在 deflate.conf 文件中。请参阅您的特定发行版的帮助文件以启用和配置 Apache 模块。

关于css - 压缩/缩小@font-face 字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1563862/

相关文章:

android - 如何更改移动字体意味着安装自定义字体到系统

css - 在网页中嵌入字体的最佳选择(SEO、速度、交叉兼容性)

java - 为什么 javafx.scene.text.Font 不可序列化?

jquery - 修复 Flexslider 标题

html - 匹配任何列宽并设置

reactjs - 移动 View 上的 CSS 格式设置有问题

apache - 重写网站 URL 以删除查询字符串变量问号?

linux - 未检测到/etc/hosts 配置

php - CSS 中的下拉菜单无法正常工作

django - Django 和 mod_wsgi : "Script timed out before returning headers: wsgi.py" 的问题