Home  >  Article  >  Backend Development  >  How to Clear Cache in Laravel 5 on Shared Hosting Without CLI Access?

How to Clear Cache in Laravel 5 on Shared Hosting Without CLI Access?

Susan Sarandon
Susan SarandonOriginal
2024-11-02 04:27:02309browse

How to Clear Cache in Laravel 5 on Shared Hosting Without CLI Access?

Clearing Cache on Shared Hosting Without CLI Access in Laravel 5

Shared hosting servers often restrict access to the command-line interface (CLI), making it challenging to execute artisan commands like cache:clear. However, there are alternative ways to clear the cache in these situations.

One workaround is to call Artisan commands directly within your code. You can do this using the Artisan::call() method in your routes file:

<code class="php">Route::get('/clear-cache', function() {
    $exitCode = Artisan::call('optimize:clear');
    // return what you want
});</code>

This code will call the optimize:clear Artisan command, which will clear the cache. You can check the Laravel documentation for more information on callingArtisan commands outside the CLI: http://laravel.com/docs/5.0/artisan#calling-commands-outside-of-cli

It's important to note that the application cache is stored in the storage/framework/cache directory only if you configured the file driver in the config/cache.php file. You can choose different cache drivers, such as Redis or Memcached, to enhance performance compared to a file-based cache.

The above is the detailed content of How to Clear Cache in Laravel 5 on Shared Hosting Without CLI Access?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn