AMP Runtime Version
Use it to query cdn.ampproject.org
for the current release or canary version of the AMP Runtime. Uses a stale-while-revalidate caching strategy to avoid network requests in the critical path.
You can use the API to re-write AMP runtime URLs to their versioned counter parts to improve browser caching, e.g. to replace:
https://cdn.ampproject.org/v0.css
with:
https://cdn.ampproject.org/rtv/001515617716922/v0.css
Installation
Install via:
npm install amp-toolbox-runtime-version
Usage
Basic usage:
const runtimeVersion = ; // Release versionruntimeVersion; // Canary versionruntimeVersion; // Rewriting cache URLsconst ampRuntimeUrl = 'https://cdn.ampproject.org/v0.js';const version = await runtimeVersion;const versionedAmpRuntimeUrl = ampRuntimeUrl;console;