Open jonluca opened 4 years ago
Sounds good! I'd prefer to name the flag more generic though: rewriteUrlsToAmpCache=cdn.ampproject.org
?
One note: rewriting script import URLs is already supported via the ampUrlPrefix flag. If the packager flag is set this should be overridden (and print a warning if it is defined as well).
Is there a reason we shouldn't just use the ampUrlPrefix
flag? It seems like the behavior is going to be the same. Is ampUrlPrefix
used elsewhere and shouldn't be overloaded?
Also, does a mapping of amp-cache-transform
headers to URLs exist somewhere already? Took a look in the amp-packager repo but didn't see anything of note.
ampUrlPrefix
is meant for runtime self-hosting. In that case you want to rewrite all script srcs, but not all asset links.
I'm not aware of an existing amp-cache-transform
header mapping - afaik, the Google AMP Cache is the only one supporting SXG.
The amp-cache-transform
header mapping is caches.json, as specified (though I'm open to PRs against the spec). For ease of implementation, this is also mirrored at https://cdn.ampproject.org/caches.json.
In practice, AMP Packager is hard-coded to support only google
but that's an open bug. No need to reproduce that buggy behavior.
Moving the conversation here based on https://github.com/ampproject/amppackager/issues/449
We’d like to move forward with adding AMP Packager compatibility mode to the AMP optimizer.
From the previous issue:
We feel comfortable in adding in a new flag (
--amp-packager-mode
?). The base URL would default tocdn.ampproject.org
, but could be changed to support different AMP caches (is this what theAMP-Cache-Transform
request header is for?).