Amphtml: Allow referencing AMP pages using Link response header

Created on 4 May 2017  路  9Comments  路  Source: ampproject/amphtml

This was previously published as a comment in issue #498 and in the AMP HTML discussion forum:

Please allow users to reference AMP pages not only using <link href="..." rel="amphtml"> HTML tags, but also using the Link: <....>; rel="amphtml" response header (as in RFC 5988), and please add this to the AMP spec.

The rationale is that by using the Link response header, a user agent does not have to download the response body in order to automatically redirect user to the AMP version of a web page (thus saving bandwidth and time). This could be achieved as a Chrome extension, which binds to webRequest.onHeadersReceived and redirects the request to the AMP page, without loading the canonical page first.

In my opinion, the Link response header should take precedence over the <link> HTML tag.

DiscussioQuestion caching

All 9 comments

/to @Gregable, @dvoytenko

Overall, Link header is a standard thing. I believe some of AMP crawlers out have to use it already, since they often restitch such headers back into crawled html for passing it around. While it's a nice optimization, I'm not sure we can require Link header in all cases since it'd be a somewhat higher barrier comparing to the <link> in HTML.

/cc @alf7

We definitely couldn't require a link header, because it wouldn't be backward compatible and would be difficult to implement for many sites.

It could be optional and take precedence, but then useragents would thus still need to download the document body, or make two requests (first a HEAD request, followed by a GET request if a link header is missing). I doubt that this pattern would offer a savings in practice to any useragents and thus would unlikely be implemented.

This could be implemented by a Chrome extension intercepting the GET response in chrome.webRequest.onHeadersReceived when there is a Link header, so there will be savings at least in lack of parsing and rendering the HTML response, compared with searching the DOM for the tag.

I think we can definitely go as far as recommending sending Link header for amphtml for canonicals.

That would be great. Thank you.

Yeah, this seems like a very reasonable thing to support, but as Greg and Dima pointed out, it's just an optimization.

There is nothing to actually do here, is there? Publishers can optionally add this header if they want, and useragents can optionally consume it if they want.

@Gregable I think your closing this issue is premature, as there is one thing to do, which is adding to the AMP spec that user agents should support referencing AMP HTML using the Link: <....>; rel="amphtml" response header too, not only using the <link rel="amphtml" href="..."> tag.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

samanthamorco picture samanthamorco  路  3Comments

gmajoulet picture gmajoulet  路  3Comments

radiovisual picture radiovisual  路  3Comments

mrjoro picture mrjoro  路  3Comments

akshaylive picture akshaylive  路  3Comments