PHP code example of atomicptr / lscache

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

    

atomicptr / lscache example snippets



// ...
class CacheResponseHeaderSlot {
    public function handle(LscacheService $lscacheService) {
        $lscacheService->headers = []; // remove headers
    }
}


// ...
class CacheTagsSlot {
    public function handle(TypoScriptFrontendController $tsfe, LscacheService $lscacheService) {
        $lscacheService->cacheTags[] = "my_fancy_cachetag";
    }
}


// ...
class CacheVariationsSlot {
    public function handle(TypoScriptFrontendController $tsfe, LscacheService $lscacheService) {
        $lscacheService->cacheVariations[] = "cookie=my_variation_cookie";
    }
}


// ...
class BeforePurgeSlot {
    public function handle(string $purgeIdentifier, LscacheService $lscacheService) {
        if ($purgeIdentifier === "*") {
            // Don't allow to purge everything (for some reason)
            $lscacheService->canPurge = false;
        }
    }
}