Does any one know how to clear the cache on laravel -9 on server
I tried it and it took me to a 404 error page
Route::get('/clear', function() {
Artisan::call('cache:clear');
Artisan::call('config:clear');
Artisan::call('config:cache');
Artisan::call('view:clear');
return "Cleared!";
});
and
Route::get('clear',[SiteController::class,'clear']);
public function clear()
{
Artisan::call('route:clear');
Artisan::call('config:clear');
Artisan::call('config:cache');
Artisan::call('view:clear');
return "Cleared!";
}
I have tried these 2 code, both are not working. and My new updates are not showing up on the site also
please help me
Thanks in advance
2
Answers
I think you can add these code to
web.php
be aware of the danger of this approach, if someone get the url of this route, they could clear your entire server’s cache at will.
instead use a QueueJob or a Schedule, if your are using CI/CD you can also invoke those command everytime you deploy