How to Disable Requirejs Cache in Magento 2 – Magento 2.3

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

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

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.