PHP code example of area17 / edge-flush

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

    

area17 / edge-flush example snippets

bash
php artisan vendor:publish --provider="A17\EdgeFlush\ServiceProvider"
bash
php artisan migrate
 php
'classes' => [
    'cdn' => A17\EdgeFlush\Services\CloudFront\Service::class,
    
    ...
]
 php
public function afterSave($object, $fields)
{
    $this->invalidateCDNCache($object);

    parent::afterSave($object, $fields);
}
 php
public function getAttribute($key)
{
    $this->cacheModelOnCDN($this);

    return parent::getAttribute($key);
}
 php
CacheControl::setMaxAge(5000); // in seconds

CacheControl::setMaxAge('1 month'); // as a DateTime string period

CacheControl::setSMaxAge('2 weeks');
 php
protected function schedule(Schedule $schedule)
{
    $schedule->job(new PurgeTags())->everyMinute();
}
 php
protected function schedule(Schedule $schedule)
{
    $schedule->job(new WarmCache())->everyMinute();
}