diff --git a/packages/optimizer/lib/transformers/RewriteAmpUrls.js b/packages/optimizer/lib/transformers/RewriteAmpUrls.js
index 7782a143e..ba0e3dfbd 100644
--- a/packages/optimizer/lib/transformers/RewriteAmpUrls.js
+++ b/packages/optimizer/lib/transformers/RewriteAmpUrls.js
@@ -67,6 +67,11 @@ class RewriteAmpUrls {
}
node = node.nextSibling;
}
+
+ if (!this._usesAmpCacheUrl(host)) {
+ const versionlessHost = calculateHost({ampUrlPrefix: params.ampUrlPrefix});
+ referenceNode = this._addMeta(head, referenceNode, 'runtime-host', versionlessHost);
+ }
}
_usesAmpCacheUrl(url) {
@@ -93,6 +98,12 @@ class RewriteAmpUrls {
insertAfter(parent, preload, node);
return preload;
}
+
+ _addMeta(parent, node, name, content) {
+ const meta = createElement('meta', {name, content});
+ insertAfter(parent, meta, node);
+ return meta;
+ }
}
module.exports = RewriteAmpUrls;
diff --git a/packages/optimizer/spec/end-to-end/hello-world/expected_output.html b/packages/optimizer/spec/end-to-end/hello-world/expected_output.html
index 62d1e50c0..55b0a3faf 100644
--- a/packages/optimizer/spec/end-to-end/hello-world/expected_output.html
+++ b/packages/optimizer/spec/end-to-end/hello-world/expected_output.html
@@ -4,6 +4,7 @@
+
diff --git a/packages/optimizer/spec/transformers/experimental/RewriteAmpUrls/rewrites_host_and_adds_version/expected_output.html b/packages/optimizer/spec/transformers/experimental/RewriteAmpUrls/rewrites_host_and_adds_version/expected_output.html
index 9edb65665..ca16813d5 100644
--- a/packages/optimizer/spec/transformers/experimental/RewriteAmpUrls/rewrites_host_and_adds_version/expected_output.html
+++ b/packages/optimizer/spec/transformers/experimental/RewriteAmpUrls/rewrites_host_and_adds_version/expected_output.html
@@ -8,6 +8,7 @@
+