PHP code example of vaersaagod / cachemate

1. Go to this page and download the library: Download vaersaagod/cachemate 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/ */

    

vaersaagod / cachemate example snippets


// Only `page` participates in the cache key; other params are stripped from the key
'cacheQueryStrings' => ['page'],

// ...or, make the whitelist strict: requests with any OTHER param aren't cached at all
'cacheQueryStrings' => ['page'],
'strictQueryParams' => true,

'enabled' => [
    '*' => true,
    'intranet' => false,
],

'excludedUriPatterns' => ['^/account', '/search'],

// or per site:
'excludedUriPatterns' => [
    '*' => ['^/account'],
    'english' => ['^/account', '^/members'],
],

'purgeRules' => [
    // News entries also purge the news listing page and the homepage
    'section:news' => ['/news', '/'],

    // Event entries only purge their own URLs
    'section:events' => [],

    // Per-site paths ('*' = fallback); trailing /* purges recursively
    'section:products' => ['*' => ['/products'], 'english' => ['/products/*']],

    // Asset changes in this volume purge the gallery section
    'volume:images' => ['/gallery/*'],

    // This global set is in the footer — everything must go
    'globalSet:footer' => 'all',
],
cron
*/15 * * * * php craft cachemate/cache/sweep
bash
# Clear everything (also available in the CP's Clear Caches utility)
php craft clear-caches/cachemate-pages
php craft cachemate/cache/clear

# Purge a specific path (optionally per site, optionally with descendants)
php craft cachemate/cache/purge /news --recursive --site=english
nginx
location / {
    try_files $cachemate_path $uri $uri/ /index.php?$query_string;
}