Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Lozza's avatar
Level 4

config/cache.php ignored

Hi folks :)

I am just learning to use cache and would like to store the keys in the database rather than a file, whilst testing, so that it is easy for me to see which keys remain after various events.

However, no matter what changes I make to the config/cache.php file (including deleting it), the cache is still saved to files and my changes are ignored.

I've tried stopping and starting the artisan serve, running cache:clear, all to no benefit!

What am I doing wrong?

Thank you Laurence

0 likes
5 replies
LaryAI's avatar
Level 58

Hello Laurence,

It sounds like your Laravel application is not recognizing the changes you've made to the config/cache.php file. Here are a few steps you can take to troubleshoot and resolve this issue:

  1. Clear Configuration Cache: Laravel caches the configuration to improve performance. After making changes to the config files, you should clear the configuration cache to ensure your changes take effect.

    Run the following Artisan command to clear the configuration cache:

    php artisan config:clear
    
  2. Clear Application Cache: Sometimes, clearing the application cache can also help.

    Run the following Artisan command to clear the application cache:

    php artisan cache:clear
    
  3. Check Cache Driver: Make sure that you have set the correct cache driver in your .env file. To use the database as your cache driver, you should have the following line in your .env file:

    CACHE_DRIVER=database
    

    After changing the .env file, you may need to clear the cache again as shown in the previous steps.

  4. Run Configuration Cache Again: After clearing the cache, you can run the configuration cache command again to cache the new configurations:

    php artisan config:cache
    
  5. Database Cache Setup: If you're using the database cache driver, ensure that you have run the necessary migration to create the cache table in your database:

    php artisan cache:table
    php artisan migrate
    
  6. Check Permissions: Ensure that the web server has the necessary permissions to read the configuration files and that the config/cache.php file is not corrupted or incorrectly formatted.

  7. Restart Queue Workers: If you are using queue workers and your cache configuration is related to jobs being processed, remember to restart your queue workers as they are long-lived processes and won't pick up config changes until they are restarted:

    php artisan queue:restart
    
  8. Check for Caching in Code: Ensure that there isn't any hardcoded caching logic in your application code that might be overriding your configuration settings.

If you've followed all these steps and the issue persists, it might be helpful to check the Laravel logs for any errors or messages that could provide more insight into the problem. The logs can typically be found in the storage/logs directory.

Remember to always back up your configuration files before making changes, and if you're working in a team, ensure that your changes are consistent across all development environments.

Snapey's avatar
Snapey
Best Answer
Level 122

try running config:clear and never cache config or run optimize in development

prove your settings by running tinker and typing config('cache') to see what Laravel thinks your current settings are

Lozza's avatar
Level 4

Cheers, not sure what did it but one of those commands solved the problem!! I never intentionally cache config! :-)

bloodykheeng's avatar

@Lozza The solution is to change the terminal if u were using the terminal in vscode close it and and go in windows search then open a new terminal then run php artisan serve

Please or to participate in this conversation.