@rabol The cache.headers middleware will add the directives to your HTTP response headers. So view them in your browser’s dev tools.
Oct 27, 2021
7
Level 14
Cache-Control header
Hi
I'm trying to set the cache-control headers on some of my routes like this:
Route::middleware('cache.headers:public;max_age=2628000;etag')->group(function () {
Route::get('/',[\App\Http\Controllers\LandingPageController::class,'index'])->name('root');
// Static pages
Route::get('about',[\App\Http\Controllers\StaticPagesController::class,'about'])->name('about');
Route::get('sustainability',[\App\Http\Controllers\StaticPagesController::class,'sustainability'])->name('sustainability');
Route::get('take-a-tour',[\App\Http\Controllers\StaticPagesController::class,'takeatour'])->name('take-a-tour');
});
When I then look at the response header via debug bar I see this:
"cache-control" => array:1 [▼
0 => "max-age=0, must-revalidate, no-cache, no-store, private"
]
The middleware configuration is from the Laravel documentation.
Did I miss something ?
Thanks
Please or to participate in this conversation.