This solution works! Create middleware using an artisan.
php artisan make:middleware RevalidateBackHistory
In the RevalidateBackHistory middleware, we set the title to no-cache and re-validate.
<?php namespace App\Http\Middleware; use Closure; class RevalidateBackHistory { public function handle($request, Closure $next) { $response = $next($request); return $response->header('Cache-Control','nocache, no-store, max-age=0, must-revalidate') ->header('Pragma','no-cache') ->header('Expires','Fri, 01 Jan 1990 00:00:00 GMT'); } }
Update Application Routing Middleware in Kernel.php
protected $routeMiddleware = [ . . 'revalidate' => \App\Http\Middleware\RevalidateBackHistory::class, . . ];
And it's all! So basically you just need to call revalidate middleware for routes that require user authentication.
Razik source share