Hello everyone. As you know, Magento 2 use the requirejs to load the JS module for the website page. So It will inscrease the loading speed of the page.

disable requirejs cache
disable requirejs cache

If the js has been loaded from server, in the next time, it will be loaded from cache of the browser. Therefore, the speed will inscrease. However, it is difficult for the developer to develop the product. Because, when you edit the JS or the .html file of knockout, you must clear the cache of the browser.

In this blog, I will show you how to disable the requirejs cache. Therefore, you don’t need to clear the cache of the browser when you develop the extension on the Magento 2.

In your module, please add the line:

urlArgs: “bust=” + (new Date()).getTime() // Disable require js cache

to your view/frontend/requirejs-config.js like this image:

Disable Requirejs Cache
Disable Requirejs Cache

After deploy the static-content, you can see that line in the pub/static/_requirejs/frontend/…/…/…/requirejs-confjg.js. So the require.js config is updated and from now, you don’t need to clear the browser cache when you develop the extension in Magento 2.

Thank you for reading this blog !


Ready to foster your knowledge

with MAGENTO 2 BASIC GUIDE

magento 2 basic guide series


How to Get all Translation Labels from PHP and JS Files of Magento 2 Extension
How to Get all Translation Labels from PHP and JS files of Magento 2 Extension

Leave a Reply

Your email address will not be published. Required fields are marked *