How to prevent laravel from caching files?

by haylee.mertz , in category: Third Party Scripts , 4 months ago

How to prevent laravel from caching files?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by darion , 4 months ago

@haylee.mertz 

To prevent Laravel from caching files, you can follow these steps:

  1. Clear the cache: You can clear the cache by running the following command in your terminal:
1
php artisan cache:clear


  1. Disable caching: If you want to disable caching entirely, you can do so by modifying the configuration file. Open the config/cache.php file and set the default cache driver to array instead of file or redis. This will prevent Laravel from caching files.
  2. Disable specific caching: If you only want to prevent specific files from being cached, you can do so by adding the dontCache() method to your code. For example:
1
2
3
Cache::remember('key', $minutes, function () {
    return dontCache('value');
});


By following these steps, you can effectively prevent Laravel from caching files.

Related Threads:

How to prevent caching in angular?
How to prevent html5 page from caching?
How to prevent caching from jquery ajax?
How to prevent caching in spring boot?
How to prevent index.php from caching?
How to prevent iframe caching in chrome?