npm

Share private packages across your team with npm Orgs, now with simplified billing via the aws marketplace!Learn more »

@ampproject/toolbox-update-cache

1.0.1 • Public • Published

AMP-Toolbox update-cache

npm version

Generates AMP Cache invalidation URLs for all known AMP Caches. For more info see the Google AMP Cache documentation.

Usage

Install via:

npm install @ampproject/toolbox-update-cache

Generate a list of update URLs like this:

  const UpdateCacheUrlProvider = require('@ampproject/toolbox-update-cache');
 
  // Load the private key, generated as described on 
  // https://developers.google.com/amp/cache/update-cache#rsa-keys
  const privateKey = '...';
 
  // Create an instance of the factory using the private key.
  const updateCacheUrlProvider = UpdateCacheUrlProvider.create(privateKey);
 
  updateCacheUrlProvider.calculateFromOriginUrl('https://www.example.com')
    .then(cacheUpdateUrls => {
      cacheUpdateUrls.forEach(cacheUpdateUrlInfo => {
        console.log('Cache ID:' + cacheUpdateUrlInfo.cacheId);
        console.log('Cache Name:' + cacheUpdateUrlInfo.cacheName);
        console.log('cache-update URL:' + cacheUpdateUrlInfo.updateCacheUrl);
      });
    });

Note: this only generates the URLs, but doesn't perform the actual update request.

install

npm i @ampproject/toolbox-update-cache

Downloadsweekly downloads

51

version

1.0.1

license

Apache-2.0

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
Report a vulnerability