Hello, This is the most common problem , when we deployed our Laravel app on Shared Hosting.
The command for clear cache using SSH or Terminal is
php artisan cache:clear
but some times when we are using Shared hosting then we don’t have ssh access .
Method 1:-
However, if you want to implement something inside the application, you can always use Artisan class.
You can call an Artisan command outside the CLI.
Create a route inside you routes/web.php.
Route::get('/clear-cache', function() { $exitCode = Artisan::call('cache:clear'); // return what you want });
Now just call this from URL.
Method 2:-
To schedule automatic execution at a particular time, establishing a cronjob is necessary.
Open app\Console\Kernel.php
and update the following code:
protected function schedule(Schedule $schedule) { $schedule->command('cache:clear')->hourly(); $schedule->command('config:clear')->hourly(); $schedule->command('view:clear')->hourly(); $schedule->command('route:clear')->hourly(); $schedule->command('optimize:clear')->hourly(); }
Thanks