Question

recently we have changed few files js/CSS/phtml files on our site as we tested them we experienced strange thing in incognito mode the new CSS and js is working fine but if we switched to normal mode it loads the old files. The issue was a browser cache as we cleared browser cache everything worked as well. But the problem is that we can't tell our every client to clear their browser cache. Is there any Solution!?

Was it helpful?

Solution 3

This method helped me I have added urlArgs: "bust=" + (new Date()).getTime() in my requirejs-config.js file now the cache issue is solved for now.

var config = {
    map: {
        '*': {
            bssAjaxCart: 'Vendor_Module/js/ajax'
        }
    },
    urlArgs: "bust=" + (new Date()).getTime()// Disable require js cache
};

REFERENCES:

magestore-blog

requirejs-doc

stackissue

OTHER TIPS

Enable cache busting on static file URLs. This ensures users get the latest version of the assets anytime they update:

php -f bin/magento config:set dev/static/sign 1

To overcome these issues Magento features Static Content Signing which allows you to invalidate Browser Cache. You can enable static content signing by navigating to Stores > Settings > Configuration > Advanced > Developer > Static Files Settings, Set Sign Static Files to Yes. Once done each time when you run the deploy command

php bin/magento setup:static-content:deploy

Magento changes the version number so automatically your static files in browser cache are invalidated due to version number change.

http://website.com/pub/static/version1475604434/frontend/Magento/luma/en_US/images/image.png

You can also enable/disable static content signing through this command

php bin/magento config:set dev/static/sign <1 or 0>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top