我拼命想找到一种方法来设置 nginx 中字体的到期日期,以在移动设备上进行优化。
我对 ttf 字体感兴趣。
我有 mime.types 作为休闲:
application/font-woff woff;
application/vnd.ms-fontobject eot;
application/x-font-ttf ttc ttf;
font/opentype otf;
image/svg+xml svg svgz;
Run Code Online (Sandbox Code Playgroud)
在 Nginx 上,我尝试了在网络上找到的所有解决方案,但均无济于事:
尝试#1:
location ~* \.(?:eot|woff|woff2|ttf|svg|otf) {
access_log off;
log_not_found off;
expires 365d;
add_header Cache-Control "public";
add_header Access-Control-Allow-Origin *;
types {font/truetype ttf;}
}
Run Code Online (Sandbox Code Playgroud)
失败 否 到期:
Request URL: http://localhost:3001/static/media/Poppins-Regular.8081832f.ttf
Request Method: GET
Status Code: 200 OK
Remote Address: [::1]:3001
Referrer Policy: strict-origin-when-cross-origin
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/x-font-ttf
Date: Thu, 01 Apr 2021 18:33:55 GMT
ETag: W/"60660e52-269f0"
Last-Modified: …Run Code Online (Sandbox Code Playgroud) 使用dart 2.0和更低版本,我可以直接导入HTTP包而无需修改pubspec.yaml文件.
我打开了一个旧项目,我得到了错误:"你的应用程序无法编译,因为它的依赖关系无法建立.那个库在一个未知的包中.也许你忘记在你的pubspec.yaml文件?"
我不得不去pubpect.yaml文件,在依赖项下我添加了:"http:^ 0.12.0"让我的项目再次运行.
发生了什么,为什么从dart核心库中删除了HTTP包?