I was working on a route that is part of a resource route. I wanted to add no-cache policy so that the page has to be fully reloaded everytime and was surprised to see that the no-cache policy was not taken into account.
Here is my route:
Route::resource('event', 'EventController')->middleware('no-cache');
And here is the content of my no-cache middleware:
public function handle(Request $request, Closure $next)
{
$response = $next($request);
return $response->header('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0')
->header('Pragma', 'no-cache')
->header('Expires', '0');
}
When browsing to /event/1/edit, the middleware is not applied.
It works fine when I have the get route in my web.php routes file:
Route::get('event/{id}/edit', 'EventController@edit')->middleware('no-cache');
Did I miss something in the documentation?