PHP code example of jeffersongoncalves / laravel-page-cache
1. Go to this page and download the library: Download jeffersongoncalves/laravel-page-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/ */
jeffersongoncalves / laravel-page-cache example snippets
return [
'enabled' => env('PAGE_CACHE_ENABLED', true),
// A TTL of 0 (or below) means "cache forever".
'ttl' => (int) env('PAGE_CACHE_TTL', 3600),
// Fold a normalized query string into the cache key (safe default).
' ],
];
use Illuminate\Support\Facades\Route;
use JeffersonGoncalves\PageCache\Middleware\CachePublicPage;
Route::middleware(['web', CachePublicPage::class])->group(function () {
Route::get('/', HomeController::class);
Route::get('/{slug}', ShowController::class);
});
use JeffersonGoncalves\PageCache\Middleware\CachePublicPage;
class ProjectObserver
{
public function saved(Project $project): void
{
CachePublicPage::flush();
}
public function deleted(Project $project): void
{
CachePublicPage::flush();
}
}