Skip to main content

I'm using magento 2.1.2 in production modeproduction mode with merge/minify/bundlemerge/minify/bundle enabled. It works good and the created files like /static/_cache/merged/6c3c8136610cacb3de381ea2afc99190.min.js has header expires setted to 1y. I think this setting is correct.

The problem is when new js changes are loaded. After flush all magento cache the new merged file contains new js changes correclty, but it has the same name as the old file, so the browser, due to the header expires, doesn't reload it and shows the old version.

To see the new changes i have to force the cache to clear with ctrl+F5.

I think a possible solution could be to give different name to merged file when they have different content or adopt a versioning system.

Do you know how to achieve this?

I'm using magento 2.1.2 in production mode with merge/minify/bundle enabled. It works good and the created files like /static/_cache/merged/6c3c8136610cacb3de381ea2afc99190.min.js has header expires setted to 1y. I think this setting is correct.

The problem is when new js changes are loaded. After flush all magento cache the new merged file contains new js changes correclty, but it has the same name as the old file, so the browser, due to the header expires, doesn't reload it and shows the old version.

To see the new changes i have to force the cache to clear with ctrl+F5.

I think a possible solution could be to give different name to merged file when they have different content or adopt a versioning system.

Do you know how to achieve this?

I'm using magento 2.1.2 in production mode with merge/minify/bundle enabled. It works good and the created files like /static/_cache/merged/6c3c8136610cacb3de381ea2afc99190.min.js has header expires setted to 1y. I think this setting is correct.

The problem is when new js changes are loaded. After flush all magento cache the new merged file contains new js changes correclty, but it has the same name as the old file, so the browser, due to the header expires, doesn't reload it and shows the old version.

To see the new changes i have to force the cache to clear with ctrl+F5.

I think a possible solution could be to give different name to merged file when they have different content or adopt a versioning system.

Do you know how to achieve this?

Source Link
LucScu
  • 2.4k
  • 28
  • 39

How to prevent browser caching for merged files?

I'm using magento 2.1.2 in production mode with merge/minify/bundle enabled. It works good and the created files like /static/_cache/merged/6c3c8136610cacb3de381ea2afc99190.min.js has header expires setted to 1y. I think this setting is correct.

The problem is when new js changes are loaded. After flush all magento cache the new merged file contains new js changes correclty, but it has the same name as the old file, so the browser, due to the header expires, doesn't reload it and shows the old version.

To see the new changes i have to force the cache to clear with ctrl+F5.

I think a possible solution could be to give different name to merged file when they have different content or adopt a versioning system.

Do you know how to achieve this?