0

We are using laravel mix (laravel 9) with vuetify 2 (vue 2) in a production environment hosted in ECS.

Our builds etc and deploy just fine, but our user base need to either refresh their browser, or on some occasions clear their caches for their browser to display the latest build.

We have followed the laravel-mix documentation and using mix.version() appropriately. Our public/js files are being hashed as expected and a refresh shows the updated ID being pulled.

But my understanding was the browser should automatically see a change a pull it without a refresh being required.

I assume we are doing something wrong.

    mix.js('resources/js/main.js', 'public/js/app.js')
        .webpackConfig(require('./webpack.config'))
        .vue()
        .vuetify('vuetify-loader', 'resources/js/assets/scss/theme.scss')
        .sass('resources/js/assets/scss/theme.scss', 'public/css/app.css')
        .version();

    mix.copyDirectory('resources/js/assets/images', 'public/images');

    if (mix.inProduction()) {
        mix.version();
    }

Please note, i added version() into the upper block for testing purposes, generally we use the if statement below to ensure this only happens in production builds.

Our mix manifest is updating as expected too.

What may we be missing here?

  • 1
    If user not refresh page - browser can't find out what version changed. – Maksim Jul 02 '23 at 11:04
  • @Maksim but surely we cannot expect to ask our entire user base to refresh their page every time we push a hotifx or feature? This seems unexpected. – Ben Martin Jul 02 '23 at 11:10
  • You can, for example, make websocket connection and notify users about hotfix - or refresh page, or reload some scripts. Maybe others give other answers, but i cannot imagine how browser can automatic know about application updates. – Maksim Jul 02 '23 at 11:17
  • 100% the user has to refresh, you are not having a live connection to the server (as @Maksim mentioned) like a websocket... how do you expect then to refresh the content if the browser (frontend) is not talking to the server asking for new data? And why do you have this weird requirement? Are you pushing every minute to have this issue? I think you have to rethink how the project is built, you should not have issues like this. I do understand if it is an SPA, but still, it is not common to read what you described. – matiaslauriti Jul 02 '23 at 15:13
  • Hm, one other option - send frontend version in every request to backend. If version changed - do something. This is not require websockets and can be implemented easy. – Maksim Jul 02 '23 at 18:26
  • the problem we have, is a lot of users seem to need to clear their browser cache which just doesn't seem right to me. I can't believe with a SPA that a user would need to clear their browser cache. Am i grossly mistaken here? @matiaslauriti we are pushing daily right now as we have just gone to market and had a far greater uptake than expected. As a result it has highlighted some bugs (minor) but pushing them out is becoming problematic. – Ben Martin Jul 03 '23 at 21:05
  • Could you share the ending of a URL asset? For example, `app.js?1234567`, does it look like that? – matiaslauriti Jul 03 '23 at 21:11
  • You can check in this SO: https://stackoverflow.com/a/2099205. location.reload(true); Though this is way back 2010 and some people say it works in IE and FF, not in chrome. – Mr. Kenneth Jul 04 '23 at 05:49
  • @BenMartin clear cache realy suck. Check your assets url in production - if they does not have random endings - than mix production function does not work. – Maksim Jul 05 '23 at 12:40

0 Answers0