PHP code example of yurikzt / html-cache-page-bundle

1. Go to this page and download the library: Download yurikzt/html-cache-page-bundle 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/ */

    

yurikzt / html-cache-page-bundle example snippets


use Yurikzt\HtmlCachePageBundle\Service\CacheCleaner;

class MyController
{
    public function __construct(private CacheCleaner $cacheCleaner) {}

    public function clearCache(): JsonResponse
    {
        $this->cacheCleaner->clearAll();
        $this->cacheCleaner->clearByPattern('/blog/*');
        $this->cacheCleaner->clearByUrl('/blog/my-post');
        $this->cacheCleaner->clearExpired();

        $stats = $this->cacheCleaner->getStats();

        return new JsonResponse(['stats' => $stats]);
    }
}