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

Luciano_Canziani's avatar

How to Update Laravel 8 + InertiaJs Cache in Production?

Hey,

I am using Laravel 8 + InertiaJs + ReactJs + MySQL with Mix. the thing is that in production the ui does not update on deploy or just appear broken for some time.

I have to delete cache or press f5 which is not good for users. I tried npm prod and production before deploy. As well as:

php artisan cache:clear php artisan route:clear php artisan config:clear php artisan view:clear php artisan optimize:clear

In local and production console in digitalocean.

I added mix.version() in webpack.mix:

const mix = require('laravel-mix');

mix.js('resources/js/app.js', 'public/js') .react() .postCss('resources/css/app.css', 'public/css') .version();

In local with npm run watch works fine, the issue is only on production.

Any other way to handle the js/css update on deploy?

0 likes
6 replies
puklipo's avatar

This is a common problem with SPA. If a JS file has been updated, display a message to reload the page.

Do not use the clear command.

1 like
ferilagi-66341611's avatar

do you using git or manual putting file in your vps? if using git, i think u can use script or command like

git pull
npm run build / npx mix
php artisan optimize

if manual putting build file in your vps just

php artisan cache:clear && php artisan optimize  

and even if u update regularly in prod u can use cronjob to update every "leisure Hours" wich is i think acceptable but not good approach.

Spa in production depend on build folder u must find a way for your need

1 like
Luciano_Canziani's avatar

@ferilagi-66341611 I currently have this scripts:

"scripts": { "dev": "npm run development", "development": "mix", "watch": "mix watch", "watch-poll": "mix watch -- --watch-options-poll=1000", "hot": "mix watch --hot", "prod": "npm run production", "production": "mix --production" },

Also tried php artisan optimize too with no luck

Please or to participate in this conversation.