7

Quoted from here: 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.

Quoted from here: https://www.ampproject.org/how-it-works/

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

Where can I find this CDN service, so I can test it? I googled a lot, but I couldn't find any information.

karel
  • 5,489
  • 46
  • 45
  • 50
Killy
  • 300
  • 5
  • 13

4 Answers4

23

To use the AMP project CDN, you can access via a URL of the form:

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

Note that the /s portion is optional and signals a secure origin, so if the origin isn't served over https, then you would use:

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

So, if we take the following URL that has an AMP equivalent: http://www.theguardian.com/childrens-books-site/2016/jan/12/sugar-tax-andy-mulligan-liquidator, looking at the source, we see the following link:

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

So, we can form a CDN URL for that AMP document as:

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

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

Barry Pollard
  • 40,655
  • 7
  • 76
  • 92
Seth Yates
  • 253
  • 2
  • 5
  • Thank you Seth. So there's no way to directly cache theguardian website ? I built this small AMP website for test: https://jure.it/ The validator doesn't return any error, but the CDN does: https://cdn.ampproject.org/c/s/jure.it/ What am i missing? Thanks – Killy Jan 14 '16 at 21:31
  • It looks like the issue is with this tag on your page: ``, specifically an issue with the extra quotes. – Gregable Jan 14 '16 at 22:10
  • So it need valid HTML too, good to know! And what i have to di if i want to cache jure.it directly, without passing through ampproject.org? (as happens wth cloudflare) – Killy Jan 14 '16 at 22:23
  • The original question was "Where can i find this CDN service, so i test it? I googled a lot but i cann't find any information." which I provided an answer to. If that answered your question, please accept my answer. As for other CDN's, I'm not aware of any others yet, but there is nothing to stop you or others from setting up your own CDN using the project. – Seth Yates Jan 15 '16 at 00:09
  • You're right Seth, i opened a [new thread](http://stackoverflow.com/questions/34802576/how-can-i-use-the-cdn-of-googles-amp-project-in-a-production-website-like-cloud) for that question. Thanks. – Killy Jan 15 '16 at 00:54
3

The CDN URL will change in 2017: https://developers.googleblog.com/2016/12/amp-cache-updates.html

Example from above:

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

If you visit the Using the Google AMP Cache page in the AMP developer documentation then there is a textbox where you can enter your original URL and it will show you the corresponding AMP cache URL.

enter image description here

Dan Diplo
  • 25,076
  • 4
  • 67
  • 89
0

For a text example with http:

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

Cache URL is:

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

With https:

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

Cache URL is (notice the /s/):

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

For an image, replace the /c/ with /i/, for example,

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

Cache URL is:

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

More details on cache URL name construction and name construction tools can be found here: https://developers.google.com/amp/cache/overview

user2468968
  • 286
  • 3
  • 9