Skip to content
Branch: master
Find file History
Latest commit 1ac4da6 Aug 7, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples use lerna.js to manage packages Oct 23, 2018
lib moved test and lint tasks to root Oct 25, 2018
spec use lerna.js to manage packages Oct 23, 2018 Fix NPM badges Aug 6, 2019
index.js use lerna.js to manage packages Oct 23, 2018
package.json v1.0.1 Aug 6, 2019
rollup.config.js Made requested changes Oct 24, 2018

AMP-Toolbox Cache URL

npm version

Translates an URL from the origin to the AMP Cache URL format, according to the specification available in the AMP documentation. This includes the SHA256 fallback URLs used by the AMP Cache on invalid human-readable cache urls.


Install via:

$ npm install @ampproject/toolbox-cache-url

Including the Module

ES Module (Browser)

import {ampToolboxCacheUrl} from 'amp-toolbox-cache-url';

CommonJs (Node)

const ampToolboxCacheUrl = require('amp-toolbox-cache-url').createCacheUrl;

UMD (Node, Browser)

In the browser, include the UMD module in an HTML <script> tag. If using node, replace window with global.

const {ampToolboxCacheUrl} = window.AmpToolboxCacheUrl;

Using the module

  // Get an AMP Cache URL from a cache domain, and a canonical URL
  ampToolboxCacheUrl.createCacheUrl('', '').then((cacheUrl) => {
    // This would log: 
    // ''

  // Transform a canonical URL to an AMP Cache subdomain
  ampToolboxCacheUrl.createCurlsSubdomain('').then((curlsSubdomain) => {
    // This would log: 
    // 'www-example-com'
You can’t perform that action at this time.