PHP code example of digitalbrands / amp-cache

1. Go to this page and download the library: Download digitalbrands/amp-cache library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

digitalbrands / amp-cache example snippets



$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);