1. Go to this page and download the library: Download atiksoftware/static-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/ */
namespace App\Http\Middleware;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Atiksoftware\StaticCache\Middleware\CacheResponse as BaseCacheResponse;
class CacheResponse extends BaseCacheResponse
{
protected function shouldCache(Request $request, Response $response)
{
// In this example, we don't ever want to cache pages if the
// URL contains a query string. So we first check for it,
// then defer back up to the parent's default checks.
if ($request->getQueryString()) {
return false;
}
return parent::shouldCache($request, $response);
}
}