Preparing application...
Clear cache, root, and config via URL in Laravel

Clear cache, root, and config via URL in Laravel

How to clear or recreate Laravel website cache, root, and config through site address. People who have experience working

44 Visit

If you have any questions, ask!

How to clear or recreate Laravel website cache, root, and config through site address. People who have experience working with Laravel know that the commands are executed through artisan, but this is when your framework is not on the host and you can apply the commands through the command environment.

Cache, root, and config via URL in Laravel

Now suppose we uploaded the site and wanted to cache it, what should we do?

Be careful, even if we cache the site with artisan, we must empty the cache after loading.

In any case, if we want to use the cache feature for different parts of Laravel, we need to enter the commands through the site address, but how?

First, enter the Routes folder in Laravel and edit the web file. We include all the code snippets you need below. At first, we put the cleaning method of each one.

Clearing Laravel cache via site address

//Clear Cache facade value:
Route::get('/clear-cache', function() {
$exitCode = Artisan::call('cache:clear');
return '<h1>Cache facade value cleared</h1>';
});

/Clear Route cache:
Route::get('/route-clear', function() {
$exitCode = Artisan::call('route:clear');
return '<h1>Route cache cleared</h1>';
});

//Clear View cache:
Route::get('/view-clear', function() {
$exitCode = Artisan::call('view:clear');
return '<h1>View cache cleared</h1>';
});

//Clear Config cache:
Route::get('/config-cache', function() {
$exitCode = Artisan::call('config:cache');
return '<h1>Clear Config cleared</h1>';
});

 Laravel cache via site address

/Cache route:
Route::get('/route-clear', function() {
$exitCode = Artisan::call('route:cache');
return '<h1>Route cache</h1>';
});

//View cache:
Route::get('/view-clear', function() {
$exitCode = Artisan::call('view:cache');
return '<h1>View cache</h1>';
});

//Config cache:
Route::get('/config-cache', function() {
$exitCode = Artisan::call('config:cache');
return '<h1>Config cache</h1>';
});

Additional explanations :

To cache different parts through artisan, the following codes are used:

php artisan optimize

php artisan config:cache
php artisan config:clear

php artisan route:cache
php artisan route:clear

php artisan view:cache
php artisan view:clear

Source » Itroz Academy

Related articles


What is MVC architecture?
Customizing the scroll bar with webkit
Array/List methods in Python
Functions in Python

Comments (0)

To send a comment please login