I think you should use:
$response = $next($request);
$response->header->set('Cache-Control' , 'public');
$response->header->set('Last-Modified', new DateTime("now"));
$response->header->set('Expires', new DateTime("tomorrow"));
return $response;
tlorentzen said:
Im trying to remove the Cache-Control: no-cache from my Laravel 5, so i created a middleware to handle this.
if(!$request->is('admin/*')) { $response = $next($request);
return $response->header('Cache-Control' , 'public')
->header('Last-Modified', new DateTime("now")) ->header('Expires', new DateTime("tomorrow")); }
Sometime the response object is instance of RedirectResponse, and for some reason that does not include a method header, but looking in the Laravel Api it should have the header method. http://laravel.com/api/5.0/Illuminate/Http/RedirectResponse.html
Does the Laravel RedirectResponse not extend the Symfony RedirectResponse? And why does the $next() return the Symfony RedirectResponse and not the Laravel RedirectResponse?
Error: Call to undefined method Symfony\Component\HttpFoundation\RedirectResponse::header()
Anyone know what to do about this?
I have the exact same problem. Did you find a solution?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community