isadma's avatar

Best way to cache js and css files on browser except laravel-mix

Hello.

Every time I reload the page, the app fetches all the css and js files. How can I cache them to prevent this and save traffic?

I need a solution other than laravel-mix.

What is the best way for caching assets for Laravel and Nginx?

0 likes
4 replies
isadma's avatar

Thank you for your reply.

Now I am adding ?v={id} end of the css and js URLs for version. For example: /css/style.css?v=1602795152

Do I need to add also ?v=... end of image files?

Sinnbeck's avatar

Well the v you are adding should only change when the asset code changes. That is how mix.version() works

If you have an image and you change the content of it, but not the name, you need to add ?v to it, or the user will see the old image (from browser cache

Please or to participate in this conversation.