Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

amp-html

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.

like image 889
user49438 Avatar asked Sep 03 '16 23:09

user49438


4 Answers

The JS should no longer be blocked in China.

like image 124
Malte Ubl Avatar answered Oct 19 '22 23:10

Malte Ubl


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

like image 45
ade Avatar answered Oct 20 '22 00:10

ade


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.
like image 34
Dorad Avatar answered Oct 20 '22 00:10

Dorad


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.

like image 37
Mr.Rebot Avatar answered Oct 19 '22 23:10

Mr.Rebot