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

mlazuardy's avatar

Laravel Versioning ( ASK ) (SOLVED)

So im using VPS to deploy my laravel apps, and using nginx as my web server. My Question is, if i cache the static assets Like This.

location ~* \.(?:css|js)$ {
  expires 1y;
  access_log off;
  add_header Cache-Control "public";
}

( including app.js and app.css from laravel mix ) and also using versioning/cache busting. is app.css and app.js will change even if it's set up like this ? Sorry bad english and Big Huge For anwering my question

0 likes
4 replies
mlazuardy's avatar

@D9705996 - So Event I Set Cache-Control while im using laravel mix, the assets (eg. app.css and app.js) will force to reload?

D9705996's avatar
D9705996
Best Answer
Level 51

When you compile you assets using mix.version() and mix.manifest is created with a unique hash of each generated asset. Then in your view if you use mix(app.css) instead of app.css. The hash only changes when the code changes so you can effectively cache your assets forever and let mix deal with versioning.

This adds the hash to your url in your view and the browser will be forced to download a new copy of the asset busting the cache even with your cache header.

You can check in the network tab of your dev tools if/when assets are loaded from the cache.

https://laravel.com/docs/5.7/mix#versioning-and-cache-busting

Please or to participate in this conversation.