1

I am working on a project where if the user logout and then click on back button in the browser, it takes me to the authenticated pages. From the code below in middleware I am able to fix this issue in chrome and firefox but still having issue on safari

namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;

class NoCacheHeaders
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse)  $next
     * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
     */
    public function handle(Request $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','0');
       // return $next($request);
    }
}

Anyone can guide me what exactly i am missing or is there any other way. I am using laravel + vuejs

0 Answers0