"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How Can I Clear Laravel 5 Cache on a Shared Hosting Server Without CLI Access?

How Can I Clear Laravel 5 Cache on a Shared Hosting Server Without CLI Access?

Published on 2024-11-02
Browse:282

How Can I Clear Laravel 5 Cache on a Shared Hosting Server Without CLI Access?

Clearing Cache on Shared Hosting Servers in Laravel 5

In Laravel 5, you can efficiently clear your cache using the cache:clear Artisan command. However, when working on a shared hosting server, you may not have access to the CLI. This raises the question:

Can I clear the cache without using CLI on a shared hosting server that lacks control panel access?

Workaround for Clearing Views Cache

While the desired command is cache:clear, it also clears other cache types. If you specifically want to clear the views cache, you can use the optimize:clear command instead. Here's a workaround to call this command outside the CLI:

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

For more information on calling Artisan commands outside of CLI, refer to the official documentation: http://laravel.com/docs/5.0/artisan#calling-commands-outside-of-cli

Understanding Cache Storage

The application cache in Laravel is typically stored in the storage/framework/cache directory. However, this may vary depending on your cache driver configuration in config/cache.php. To optimize performance, consider using a different driver like Redis or Memcached.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3