Google AMP 页面的 CDN 未缓存自托管网络字体
Self-hosted webfonts not being cached by Google CDN for AMP pages
我的公司最近开始为我们的一个网站试验 AMP 页面。这个过程非常有效,我们看到 Google 索引我们的页面以用于 AMP 轮播:Mobile Google Search result for PennLive.com.
但是,我们的字体资源在 Google 轮播中返回为 404,尽管它们直接在我们的 AMP 页面上工作。
https://cdn.ampproject.org/r/www.pennlive.com/static/common/fonts/v1/benton-sans-medium/448c4642-c106-472f-9c6a-a4d7b5347b03-3.woff
returns 404
鉴于:
http://www.pennlive.com/static/common/fonts/v1/benton-sans-medium/448c4642-c106-472f-9c6a-a4d7b5347b03-3.woff
returns 200
在 amphtml 文档中,它说自托管字体必须通过 http 或 https 提供,这就是我们正在为我们的页面所做的,并且 AMP 页面显然正在验证。
为什么这些字体在 Google AMP 轮播中不返回 200?
示例页面:http://www.pennlive.com/articles/18505993/penn_state_commit_damion_barbe.amp
看到您的 AMP
页面会很有帮助;否则我试图推断可能发生的事情。
Font Awesome 字体也有类似的问题。终于发现了这个方法:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha256-MfvZlkHCEqatNoGiOXveE8FIwMzZg4W85qfrfIFBfYc= sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ=="
crossorigin="anonymous"
>
我看到 benton-sans-medium 可能是您已获得许可的字体。如果他们会为您提供字体,上述方法可能会有用。
您的服务器返回的 .woff 字体文件的内容类型无效。
$ curl -I http://www.pennlive.com/static/common/fonts/v1/benton-sans-medium/448c4642-c106-472f-9c6a-a4d7b5347b03-3.woff
HTTP/1.1 200 OK
Date: Fri, 20 May 2016 17:27:48 GMT
Last-Modified: Wed, 18 May 2016 15:03:07 GMT
Accept-Ranges: bytes
Cache-Control: max-age=604800
Expires: Fri, 27 May 2016 17:27:48 GMT
Content-Type: text/plain; charset=UTF-8
X-Varnish: 198714588
Via: 1.1 varnish-v4
X-ADI-VCache: MISS
Content-Length: 54040
Connection: keep-alive
备注Content-Type: text/plain;
我想你想要 application/x-font-woff
或 font/woff
我的公司最近开始为我们的一个网站试验 AMP 页面。这个过程非常有效,我们看到 Google 索引我们的页面以用于 AMP 轮播:Mobile Google Search result for PennLive.com.
但是,我们的字体资源在 Google 轮播中返回为 404,尽管它们直接在我们的 AMP 页面上工作。
https://cdn.ampproject.org/r/www.pennlive.com/static/common/fonts/v1/benton-sans-medium/448c4642-c106-472f-9c6a-a4d7b5347b03-3.woff
returns 404
鉴于:
http://www.pennlive.com/static/common/fonts/v1/benton-sans-medium/448c4642-c106-472f-9c6a-a4d7b5347b03-3.woff
returns 200
在 amphtml 文档中,它说自托管字体必须通过 http 或 https 提供,这就是我们正在为我们的页面所做的,并且 AMP 页面显然正在验证。
为什么这些字体在 Google AMP 轮播中不返回 200?
示例页面:http://www.pennlive.com/articles/18505993/penn_state_commit_damion_barbe.amp
看到您的 AMP
页面会很有帮助;否则我试图推断可能发生的事情。
Font Awesome 字体也有类似的问题。终于发现了这个方法:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha256-MfvZlkHCEqatNoGiOXveE8FIwMzZg4W85qfrfIFBfYc= sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ=="
crossorigin="anonymous"
>
我看到 benton-sans-medium 可能是您已获得许可的字体。如果他们会为您提供字体,上述方法可能会有用。
您的服务器返回的 .woff 字体文件的内容类型无效。
$ curl -I http://www.pennlive.com/static/common/fonts/v1/benton-sans-medium/448c4642-c106-472f-9c6a-a4d7b5347b03-3.woff
HTTP/1.1 200 OK
Date: Fri, 20 May 2016 17:27:48 GMT
Last-Modified: Wed, 18 May 2016 15:03:07 GMT
Accept-Ranges: bytes
Cache-Control: max-age=604800
Expires: Fri, 27 May 2016 17:27:48 GMT
Content-Type: text/plain; charset=UTF-8
X-Varnish: 198714588
Via: 1.1 varnish-v4
X-ADI-VCache: MISS
Content-Length: 54040
Connection: keep-alive
备注Content-Type: text/plain;
我想你想要 application/x-font-woff
或 font/woff