如何“利用浏览器缓存”获取Google字体? [英] How do I 'leverage browser caching' for Google fonts?

查看:172
本文介绍了如何“利用浏览器缓存”获取Google字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过Pingdom测试了我的网站,并得到了它:

I tested my site via Pingdom and got this:

我进行了搜索,但找不到解决方案。有人知道我怎么能得到这14到100?

I searched but couldn't find a solution to this. Does anyone know how I can get this 14 to 100?

推荐答案

由于您无法控制Google标头(包括到期标头),我只能看到一种解决方案-将这两种样式表和字体下载到您自己的托管服务器上,并相应地更改HTML标签。

Since you cannot control Googles headers (including expiration headers), I can see only one solution – download these two stylesheets and fonts to your own hosting server, change HTML tags accordingly.

然后,您可以设置过期标头(Pingdom称为

Then, you can set expiration headers (what Pingdom called 'lifetime') as you wish.

例如,打开第一个链接

/* latin */
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 400;
  src: local('Montserrat-Regular'), url(http://fonts.gstatic.com/s/montserrat/v6/zhcz-_WihjSQC0oHJ9TCYAzyDMXhdD8sAj6OAJTFsBI.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}

下载此.woff2文件并将其保存在Web服务器上的任何位置。复制和将此样式表粘贴到您自己的任何CSS文件或HTML中。将链接从fonts.gstatic.com更改为您的新URL。

Download this .woff2 file and save it anywhere on your webserver. Copy & paste this piece of stylesheet into any of your own CSS files or HTML. Change the link from fonts.gstatic.com to your new URL.

Google提供的这些字体的有效期为1天。您现在可以轻松地将其设置为30天。

Google serves these fonts with expiration time of 1 day. You could easily set it to 30 days now.

这篇关于如何“利用浏览器缓存”获取Google字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆