Step1: Create a middleware using artisan:
php artisan make:middleware PreventBackHistory
Step2: Replace content of PreventBackHistory.php with following content:

<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class PreventBackHistory
{
    /**
     * Handle an incoming request.
     *
     * @param  \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response)  $next
     */
    public function handle(Request $request, Closure $next): Response
    {
        $response = $next($request);
        $response->headers->set('Cache-Control', 'nocache, no-store, max-age=0, must-revalidate');
        $response->headers->set('Pragma', 'no-cache');
        $response->headers->set('Expires', 'Sun, 02 Jan 1990 00:00:00 GMT');
        return $response;
    }
}

Step3: Register middleware in kernal.php
'preventBackHistory' => \App\Http\Middleware\PreventBackHistory::class,
Step4: Add 'preventBackHistory' to middleware protected routes in routes/web.php
Route::middleware(['preventBackHistory','otherMiddlewareClasses'])->group(function () {
This is done, now check it will work as per the expected.