如何测试 Google 的 AMP 项目的 CDN?

How can I test the CDN of Google's AMP Project?

引自此处:https://www.ampproject.org/docs/get_started/about-amp.html

AMP is a way to build web pages for static content that render fast. AMP in action consists of three different parts:

  • AMP HTML
  • AMP JS
  • AMP CDN

AMP HTML is HTML with some restrictions for reliable performance and some extensions for building rich content beyond basic HTML. The AMP JS library ensures the fast rendering of AMP HTML pages. The AMP CDN (optionally) delivers the AMP HTML pages.

引自此处:https://www.ampproject.org/how-it-works/

Google is offering a service that delivers AMP HTML documents given their URL through its CDN.

在哪里可以找到这个 CDN 服务,以便我可以测试它?我用谷歌搜索了很多,但找不到任何信息。

要使用 AMP 项目 CDN,您可以通过以下形式的 URL 访问:

https://cdn.ampproject.org/c/s/<origin-domain>/<path>

请注意,/s 部分是可选的,表示安全来源,因此如果来源不是通过 https 提供的,那么您将使用:

https://cdn.ampproject.org/c/<origin-domain>/<path>

因此,如果我们采用以下具有 AMP 等效项的 URL:http://www.theguardian.com/childrens-books-site/2016/jan/12/sugar-tax-andy-mulligan-liquidator,查看源代码,我们会看到以下内容 link:

<link rel="amphtml" href="https://amp.theguardian.com/childrens-books-site/2016/jan/12/sugar-tax-andy-mulligan-liquidator">

因此,我们可以为该 AMP 文档构建一个 CDN URL:

https://cdn.ampproject.org/c/s/amp.theguardian.com/childrens-books-site/2016/jan/12/sugar-tax-andy-mulligan-liquidator

来源:https://github.com/ampproject/amphtml/blob/master/src/service/cid-impl.js#L201

CDN URL 将在 2017 年发生变化: https://developers.googleblog.com/2016/12/amp-cache-updates.html

上面的例子:

https://amp-theguardian-com.cdn.ampproject.org/c/s/amp.theguardian.com/childrens-books-site/2016/jan/12/sugar-tax-andy-mulligan-liquidator

对于带有 http 的文本示例:

http://example.com/blog/index.html

缓存 URL 是:

https://example-com.cdn.ampproject.org/c/example.com/blog/index.html

使用 https:

https://example.com/blog/index.html

缓存 URL 是(注意 /s/):

https://example-com.cdn.ampproject.org/c/s/example.com/blog/index.html

对于图片,将/c/替换为/i/,例如

http://example.com/blog/picture.jpeg

缓存 URL 是:

https://example-com.cdn.ampproject.org/i/s/example.com/blog/picture.jpeg

有关缓存 URL 名称构造和名称构造工具的更多详细信息,请参见此处:https://developers.google.com/amp/cache/overview

如果您访问 AMP 开发人员文档中的 Using the Google AMP Cache page,则会有一个文本框,您可以在其中输入原始 URL,它会显示相应的 AMP 缓存 URL。