简体   繁体   English

CDNed AMP 页面的正确链接 URL

[英]Proper Link URL for CDNed AMP Pages

I made the static portion of a mobile website amp-compliant, but I'm unsure if there are any further steps necessary in addition to that.我使移动网站的静态部分与 amp 兼容,但我不确定除此之外是否还有其他必要的步骤。

In particular, is it ok (or perhaps even necessary?) to force users to load the pages over Google's CDN, by rewriting website-internal links to the CDN URL of the page?特别是,通过将网站内部链接重写为页面的 CDN URL 来强制用户通过 Google 的 CDN 加载页面是否可以(或者甚至有必要?)? ie something like <a href="http_s_://cdn.ampproject.org/c/s/example.net/b.html">...</a> ?即像<a href="http_s_://cdn.ampproject.org/c/s/example.net/b.html">...</a>类的东西? Or will that somehow mess up Google's Crawler?或者这会以某种方式弄乱谷歌的爬虫?

In fact, I already tried it briefly, but the pages keep opening in new tabs when clicking the links, even if the current page was loaded over its CDN URL.事实上,我已经简单地尝试过,但是单击链接时页面会在新选项卡中打开,即使当前页面是通过其 CDN URL 加载的。 Is that intentional?这是故意的吗? I tried using target="_top", but apparently that is disallowed for compliant amp-html.我尝试使用 target="_top",但显然这对于​​兼容的 amp-html 是不允许的。

So what is the recommended solution here?那么这里推荐的解决方案是什么?

It certainly isn't necessary to link to the AMP Cache's copy of your pages.当然没有必要链接到 AMP Cache 的页面副本。 If you want to, you can, and in theory the CDN links should work indefinitely.如果你愿意,你可以,而且理论上 CDN 链接应该无限期地工作。 Per the AMP Cache Guidelines , an AMP Cache:根据AMP 缓存指南,AMP 缓存:

  • Pledges to maintain URL space forever (even beyond the lifetime of the cache itself):承诺永远维护 URL 空间(甚至超过缓存本身的生命周期):
    • This can be achieved by donating the URL space to a trustworthy third party entity such as archive.org.这可以通过将 URL 空间捐赠给可信赖的第三方实体(例如 archive.org)来实现。
    • This means that, should a cache decide to no longer operate, URLs should redirect to the origin URL or be served by another cache.这意味着,如果缓存决定不再运行,URL 应该重定向到源 URL 或由另一个缓存提供服务。

I chose to make my AMP pages link directly to my own copies of my other AMP pages, though, because I had a minor issue with the Google AMP Cache failing to serve some of my images and wanted to make sure that I'd be able to quickly fix things if my pages were improperly served by the cache due to other bugs or validation problems.不过,我选择让我的 AMP 页面直接链接到我自己的其他 AMP 页面的副本,因为我遇到了一个小问题,即 Google AMP 缓存无法提供我的某些图像,并希望确保我能够如果我的页面由于其他错误或验证问题而被缓存不正确地提供,以快速修复问题。 Ultimately, it's your call whether to link to your canonical non-AMP pages, your AMP pages, or the cache's copies of your AMP pages.最终,是链接到规范的非 AMP 页面、AMP 页面还是 AMP 页面的缓存副本由您决定。

See also this amphtml feature request requesting the ability to ask the AMP cache to rewrite links to point to either CDN or non-CDN versions of pages when possible.另请参阅此 amphtml 功能请求,该请求请求能够请求 AMP 缓存重写链接以在可能的情况下指向 CDN 或非 CDN 版本的页面。 Speculating more wildly, I could imagine browsers someday offering to do this rewriting automatically as you browse.更疯狂地推测,我可以想象有一天浏览器会在您浏览时自动进行这种重写。 I haven't tried it, but there appears to already be at least one Chrome extension that loads AMP versions of pages when they're available .我还没有尝试过,但似乎至少有一个 Chrome 扩展程序可以在页面可用时加载 AMP 版本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM