首页 > 解决方案 > CSS Font Face 在 chrome 开发者工具中发出多个请求

问题描述

我正在使用字体从服务器下载字体文件。

问题是,当我看到 chrome 网络选项卡时,我看到多个请求获取相同的字体文件。

发出的第一个请求有 200 状态码,其余请求有 304(未修改)

有趣的是,这只发生在 chrome 中。我在 safari 和 firefox 中进行了测试,他们只发送一个请求。

下面是我的代码片段

@font-face {
    font-family: 'MyFont';
    src: url('https://example.com/font.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}
$font-family: 'MyFont', sans-serif !important;
$font-weight: 400;

请让我知道你的意见

标签: cssgoogle-chromesassgoogle-chrome-devtoolsfont-face

解决方案


推荐阅读