ennexa/amp-update-cache

PHP 类用于清除 Google AMP 缓存

0.1 2020-10-01 13:48 UTC

This package is auto-updated.

Last update: 2024-09-24 23:19:16 UTC


README

一个简单的 PHP 类,用于更新 Google AMP 缓存

安装

composer require ennexa/amp-update-cache:dev-master

使用

要清除 https://www.prokerala.com/health/?amp=1 的缓存

$var = new Ennexa\AmpCache\Update(PATH_TO_YOUR_PRIVATE_KEY); // Make sure your private key is outside document root

$status = $var->purge('https://www.prokerala.com/health/?amp=1');

该脚本将从 AMP 项目 官方缓存列表 中列出的所有缓存中清除缓存 URL。

如果您只想清除 Google 的 AMP 缓存,您可以按以下方式过滤列表

$updater = new Ennexa\AmpCache\Update(PATH_TO_YOUR_PRIVATE_KEY);
$updater->setCache(array_filter($updater->getCache(), function($cache) {
    return 'google' === $cache->id;
}));
$status = $updater->purge('https://www.prokerala.com/health/?amp=1');