@ampproject/toolbox-cache-list

2.9.0 • Public • Published

AMP-Toolbox Cache List

npm version

Lists known AMP Caches, as available at https://cdn.ampproject.org/caches.json.

By default, it uses a one-behind caching strategy to fetch the caches. This can be customised by passing a custom fetch strategy to the constructor.

Usage

Install via:

$ npm install @ampproject/toolbox-cache-list

List all known caches:

  const Caches = require('@ampproject/toolbox-cache-list');

  const allCaches = await Caches.list();

Which will return an array similar to:

[
  {
    "id": "google",
    "name": "Google AMP Cache",
    "docs": "https://developers.google.com/amp/cache/",
    "cacheDomain": "cdn.ampproject.org",
    "updateCacheApiDomainSuffix": "cdn.ampproject.org",
    "thirdPartyFrameDomainSuffix": "ampproject.net"
  },
  {
    "id": "bing",
    "name": "Bing AMP Cache",
    "docs": "https://www.bing.com/webmaster/help/bing-amp-cache-bc1c884c",
    "cacheDomain": "www.bing-amp.com",
    "updateCacheApiDomainSuffix": "www.bing-amp.com",
    "thirdPartyFrameDomainSuffix": "www.bing-amp.net"
  }
]

Fetching info about a specific AMP cache via the cache id:

  const Caches = require('@ampproject/toolbox-cache-list');

  const googleAmpCache = await Caches.get('google');

Which will return:

{
  "id": "google",
  "name": "Google AMP Cache",
  "docs": "https://developers.google.com/amp/cache/",
  "cacheDomain": "cdn.ampproject.org",
  "updateCacheApiDomainSuffix": "cdn.ampproject.org",
  "thirdPartyFrameDomainSuffix": "ampproject.net"
}

Package Sidebar

Install

npm i @ampproject/toolbox-cache-list

Weekly Downloads

447

Version

2.9.0

License

Apache-2.0

Unpacked Size

16.5 kB

Total Files

5

Last publish

Collaborators

  • ampproject-admin
  • kristoferbaxter
  • jridgewell
  • choumx
  • amp-toolbox
  • fstanis
  • erwinmombay
  • samouri
  • caroqliu
  • rsimha
  • dvoytenko
  • patrickkettner
  • alanorozco
  • kdwan
  • ampprojectbot
  • esth