【问题标题】:How to store font in google chrome manually?如何手动将字体存储在谷歌浏览器中?
【发布时间】:2020-06-16 09:08:05
【问题描述】:

我有一个名为“Jameel Noori Nastaliq”的字体。它是 urdu 字体,有 10MB 的 .ttf 文件。我在我的网站上使用过它。但是当我的网站加载时,完成整个页面的加载需要很长时间。

我尝试将其更改为 woff 或压缩它,但没有成功。这是字体 .ttf 文件的下载链接。 https://urdufonts.net/fonts/jameel-noori-nastaleeq-regular#

【问题讨论】:

    标签: html performance web flask fonts


    【解决方案1】:

    您只能在每个用户加载一次字体后缓存该字体。您可以通过在htaccess中添加以下内容来管理字体的缓存:

    <IfModule mod_expires.c>
        ExpiresActive on
        ExpiresDefault                              "access plus 1 month"
        ExpiresByType text/cache-manifest           "access plus 0 seconds"
        # Webfonts
        ExpiresByType font/ttf                      "access plus 4 months"
        ExpiresByType font/otf                      "access plus 4 months"
        ExpiresByType font/woff                     "access plus 4 months"
        ExpiresByType font/woff2                    "access plus 4 months"
        ExpiresByType image/svg+xml                 "access plus 1 month"
        ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
    </IfModule>
    

    【讨论】:

    • 谢谢你的回答,你能指导我如何在Server: Werkzeug/1.0.1 Python/3.6.9上缓存
    • 抱歉,不知道如何添加到 Python 服务器 - 只知道 apache htaccess。复制并粘贴我的答案,并提出一个关于如何将等效规则放入您的配置的新问题。
    猜你喜欢
    • 2012-11-29
    • 2012-07-05
    • 2012-08-17
    • 2012-05-06
    • 1970-01-01
    • 2012-01-21
    • 2018-03-24
    • 2017-05-25
    • 2013-12-18
    相关资源
    最近更新 更多