PHP code example of chesio / bc-cache
1. Go to this page and download the library: Download chesio/bc-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/ */
chesio / bc-cache example snippets
define('BC_CACHE_WARM_UP_ENABLED', false);
define('BC_CACHE_FILE_LOCKING_ENABLED', false);
add_filter('bc-cache/filter:request-variant', function (string $default_variant): string {
return cn_cookies_accepted() ? '_cna' : $default_variant;
}, 10, 1);
add_filter('bc-cache/filter:request-variants', function (array $variants): array {
$variants['_cna'] = 'Cookie notice accepted';
return $variants;
}, 10, 1);
add_filter('bc-cache/filter:cache-warm-up-invocation-delay', function (): int { return 5 * MINUTE_IN_SECONDS; }, 10, 0);
add_filter('bc-cache/filter:cache-warm-up-run-timeout', '__return_zero', 10, 0);
add_filter('bc-cache/filter:cache-warm-up-request-arguments', function (array $args, string $url, string $request_variant): array {
if ($request_variant === '_cna') {
$args['cookies'] = [
'cookie_notice_accepted' => 'true',
];
}
return $args;
}, 10, 3);