AMP 工具箱缓存列表
已知的 AMP Caches 列表, 可用于 https://cdn.ampproject.org/caches.json。 。 。 .
默认情况下,它使用一后隐蔽策略来取取缓存. 这可以被定制为: 将自定义获取策略传递给构建者 .
使用量
通过 :
$ npm install @ampproject/toolbox-cache-list
列出所有已知缓存 :
const Caches = require('@ampproject/toolbox-cache-list');
const allCaches = await Caches.list();
这将返回一个类似于 :
[
{
"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"
}
]
通过缓存 ID 获取关于特定 AMP 缓存的信息 :
const Caches = require('@ampproject/toolbox-cache-list');
const googleAmpCache = await Caches.get('google');
将返回 :
{
"id": "google",
"name": "Google AMP Cache",
"docs": "https://developers.google.com/amp/cache/",
"cacheDomain": "cdn.ampproject.org",
"updateCacheApiDomainSuffix": "cdn.ampproject.org",
"thirdPartyFrameDomainSuffix": "ampproject.net"
}