amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Preconnect to resources within A4A Fast Fetched AMP Creatives

Open keithwrightbos opened this issue 9 years ago • 10 comments

Resource within AMP creatives returned by A4A Fast Fetch are likely to have different domains than the CDN given they are not rewritten as part of validation. In order to reduce time to resource fetch, preconnect to resource domains as soon as validation is complete. Easiest solution would be to have the validator provide this information which could be returned as part of the creative.

keithwrightbos avatar Feb 17 '17 18:02 keithwrightbos

cc/ @tdrl @dknecht

Greg, would seem the easiest thing to do would be to include as part of validator data. Is that relatively simple?

keithwrightbos avatar Feb 17 '17 18:02 keithwrightbos

One question. We were doing it already by adding the pre-connect into a4a content. Are you suggesting we ad to metadata that is passed to parent runtime and let it handle?

dknecht avatar Feb 17 '17 19:02 dknecht

Yes because the ad content is not injected into the DOM until layoutCallback which is traditionally 3 viewports. Idea is to allow for prefetch as soon as creative is verified as AMP.

On Fri, Feb 17, 2017, 2:58 PM Dane [email protected] wrote:

One question. We were doing it already by adding the pre-connect into a4a content. Are you suggesting we ad to metadata that is passed to parent runtime and let it handle?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/ampproject/amphtml/issues/7640#issuecomment-280751051, or mute the thread https://github.com/notifications/unsubscribe-auth/ABr0L5-N8i_3Sy9A_ZDK4795lv7aj0Rsks5rdfvTgaJpZM4MEnWm .

keithwrightbos avatar Feb 19 '17 20:02 keithwrightbos

I mean to say preconnect instead of prefetch however in your case I assume you have already rewritten the creative so all resources on on the same domain as the ad request in which case this has no benefit. This is not th case for AdSense/DoubleClick given we do not traditionally CDN a creatives resources

On Sun, Feb 19, 2017, 3:53 PM Keith Wright [email protected] wrote:

Yes because the ad content is not injected into the DOM until layoutCallback which is traditionally 3 viewports. Idea is to allow for prefetch as soon as creative is verified as AMP.

On Fri, Feb 17, 2017, 2:58 PM Dane [email protected] wrote:

One question. We were doing it already by adding the pre-connect into a4a content. Are you suggesting we ad to metadata that is passed to parent runtime and let it handle?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/ampproject/amphtml/issues/7640#issuecomment-280751051, or mute the thread https://github.com/notifications/unsubscribe-auth/ABr0L5-N8i_3Sy9A_ZDK4795lv7aj0Rsks5rdfvTgaJpZM4MEnWm .

keithwrightbos avatar Feb 19 '17 21:02 keithwrightbos

Mostly correct. For now we are re-writing to a single 3rd party domain and in the future might switch that over to be the same.

dknecht avatar Feb 19 '17 21:02 dknecht

Is there a significant speedup here? The preconnect is usually used for resources not referenced in the document, for which the browser can predict the connection to. Once the ad is loaded, we already have the amp runtime loaded as well, so presumably just creating the dom nodes will do everything we need. I am not an expert here.

Gregable avatar Feb 22 '17 19:02 Gregable

We do not actually write the creative to the DOM until it is within 3 viewports (at which point the browser can connect) however its possible to get the creative well before then. Preconnecting should have some effect though I cannot easily quantify how much. Wanted to gauge the amount of effort required for you to provide the domains. Thanks!

On Wed, Feb 22, 2017 at 2:27 PM Greg Grothaus [email protected] wrote:

Is there a significant speedup here? The preconnect is usually used for resources not referenced in the document, for which the browser can predict the connection to. Once the ad is loaded, we already have the amp runtime loaded as well, so presumably just creating the dom nodes will do everything we need. I am not an expert here.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/ampproject/amphtml/issues/7640#issuecomment-281774882, or mute the thread https://github.com/notifications/unsubscribe-auth/ABr0L2s2I6bqtC7_KQUwR9vBZTV22aSRks5rfIwqgaJpZM4MEnWm .

keithwrightbos avatar Feb 22 '17 21:02 keithwrightbos

It seems doable, they are being parsed as URLs. We'd need to build a list of which URLs are resources we want (ie: <amp-img src>) and which are resources we don't want (ie: <a href>).

Gregable avatar Feb 23 '17 00:02 Gregable

This issue hasn't been updated in awhile. @Gregable Do you have any updates?

ampprojectbot avatar Dec 12 '17 04:12 ampprojectbot

This is already supported for images (still running as an experiment). Fast Fetch already preloads extensions and fonts.

keithwrightbos avatar Dec 12 '17 15:12 keithwrightbos