digitalbrands/amp-cache

更新 AMP 缓存的工具

v2.4.1-beta 2019-04-01 12:44 UTC

This package is auto-updated.

Last update: 2024-09-29 05:02:07 UTC


README

Build Status

AMP 更新缓存库

有时你需要告诉 Google 更新你的 AMP 页面的缓存。了解更多: https://developers.google.com/amp/cache/update-cache

这个库是一个简单的工具来实现这个功能。你需要的是私有 API 密钥和要更新的 URL。

使用方法

<?php
$ampCache = \DigitalBrands\AmpCache\Cache::create('<YourPrivateApiKey>');

$ampCache->update('<YourAMPUrl>');
//or
$ampCache->updateBatch(['<YourAMPUrl1>', '<YourAMPUrl2>'])

配置

$config=[
    'cache_list_url' => 'https://cdn.ampproject.org/caches.json', //A url servers list will be downloaded from. Default https://cdn.ampproject.org/caches.json
    'servers' => ['cdn.ampproject.org'], //an array of cache servers. Then client will not download them from cache list url
    'timeout' => 5, //A timeout for updating single url on particular cache server. Default 5.
    'exception_on_group' => false, //If true then exception will be thrown only when all cache servers return bad response (not 200 code). If there is only one server in cache, then this option will be ignored
];

$ampCache = \DigitalBrands\AmpCache\Cache::create('<YourPrivateApiKey>', $config);