In the Laravel docs it's advised to run ./artisan config:cache
in production to speed things up. That's great with Heroku since every build brings up a new filesystem state, so we don't even have to bother with clearing the cache between deploys.
BUT: if you add that command to your deployment procedure (via Composer for instance) your Laravel app will start crashing, since it'll be looking for files in the now-gone build paths (something like /tmp/random_string
). If you run heroku run pwd
you'll notice the runtime app lives on /app
.
It seems ./artisan config:cache
stores the temporary build path in the cached settings, while the app runs in another path. Is it possible to change the path used in the resulting config cache?
The cache configuration is located at config/cache. php . In this file you may specify which cache driver you would like used by default throughout your application. Laravel supports popular caching backends like Memcached and Redis out of the box.
To clear your application cache, you may run the following Artisan command: $ php artisan cache:clear Application cache cleared! This will clear all the cache data in storage which are typically stored in /storage/framework/cache/data/ .
Memcache is a technology that improves the performance and scalability of web apps and mobile app backends. You should consider using Memcache when your pages are loading too slowly or your app is having scalability issues. Even for small sites, Memcache can make page loads snappy and help future-proof your app.
php artisan config:clear Laravel stores all the configuration from App/config directory to a single cached config file at App/bootstrap/cache/config.
You'd best do this at boot and not at build time. In order to do so you need to modify you composer.json to add:
"warmup": [
"php artisan config:cache",
"php artisan route:cache"
],
And then modify your procfile to something like web: composer warmup && $(composer config bin-dir)/heroku-php-apache2 public/
Credits for the tip goes to David from the Heroku support!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With