Is it possible to use an alternate CDN for AMP as ampproject.org is blocked in China?
Asked Answered
M

4

5

Is there a way to use an alternate CDN for including the main JavaScript file AMP needs? Can a different URL than https://cdn.ampproject.org/v0.js be used? Are there plans to open this up a bit more by allowing other CDNs that aren't blocked in China, etc?

Using several of the top proxies returned from a web search, it appears that ampproject.org is blocked in China. This isn't too surprising as other Google properties are blocked.

Edit: I should mention I tried copying the file and running it locally, but the AMP validator throws an error when I try that.

Midship answered 3/9, 2016 at 23:52 Comment(1)
China has their own AMP clone called MIP.Brokaw
L
1

Unfortunately, I think the source file of the main Javascript the AMP need is only accessible using the https://cdn.ampproject.org URL.

According to the blog "Getting started with AMP Html, accelerated mobile pages"

AMP does this by creating new rules for bottlenecks: JavaScript and html elements that are considered slow are prohibited. JavaScript is only allowed using libraries provided by the CDN of Google itself.

Also in their official web page:

Our goal with AMP HTML is reliable performance, so we designed it to be easily cacheable by content delivery networks (CDNs). Google is offering a service that delivers AMP HTML documents given their URL through its CDN. Others can use this service or make their own or serve AMP HTML pages from a plain-old-web-server.

Laudation answered 5/9, 2016 at 11:47 Comment(0)
P
4

The JS should no longer be blocked in China.

Predecessor answered 7/9, 2016 at 17:24 Comment(0)
P
3

Cloudflare now provides an alternative to Google's AMP cache: https://blog.cloudflare.com/accelerated-mobile/

Pasta answered 26/1, 2017 at 15:37 Comment(0)
D
3

Matt Mower posted a gist explaining how to self-host AMP framework. That worked for me.

summary of his post:

  1. Build AMP framework / download dist files (listed here)
  2. Serve them from the same http server as AMP HTML file.
  3. Replace scripts src attributes. I.E: <script async src="https://cdn.ampproject.org/v0.js"></script><script async src="<path_to_amp_files>/v0.js"></script>
  4. Customize runtime-host meta tag. Prepend <meta name="runtime-host" content="<path_to_amp_files>"> before any script tags in head element.
  5. There is a little more workaround for amp-geo-api in the gist.
Desireedesiri answered 14/4, 2020 at 8:44 Comment(0)
L
1

Unfortunately, I think the source file of the main Javascript the AMP need is only accessible using the https://cdn.ampproject.org URL.

According to the blog "Getting started with AMP Html, accelerated mobile pages"

AMP does this by creating new rules for bottlenecks: JavaScript and html elements that are considered slow are prohibited. JavaScript is only allowed using libraries provided by the CDN of Google itself.

Also in their official web page:

Our goal with AMP HTML is reliable performance, so we designed it to be easily cacheable by content delivery networks (CDNs). Google is offering a service that delivers AMP HTML documents given their URL through its CDN. Others can use this service or make their own or serve AMP HTML pages from a plain-old-web-server.

Laudation answered 5/9, 2016 at 11:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.