I am working on Magento 2 knockout js. But when I am changing HTML or js file it's not effecting on frontend I run all this command

setup:upgrade, static:content:deploy, di:compile, cace:flush

But sometimes these files changed and sometimes not changed.

Anyone guide me how can we resolve this type of issue in Magento 2?


Try to clear Browser Cache or Disable it when developing.

One more tip: to make sure our Js or HTML static files change or not. Search them on Network tab (Chrome Browser), open in new tab and check it.

enter image description here

  • 1
    This is very useful trick. We need not clear all browser cache for just one file change. If we open a file in the new tab and file not changed than just refresh new tab to see changes. I do this same all the time when working with HTML and js changes. – Prince Patel Dec 15 '17 at 10:26
  • You can try this with ctrl+f5 in chrome sometimes x3 All browser have short to refresh with cleaning cache – BartZalas Jul 5 '18 at 10:12

There are some ways to revolve your issue (make sure you're in developer mode):

  1. Use command combination: php bin/magento setup:upgrade and php bin/magento static:content:deploy. setup:upgrade will clean all generated code, static content and var/view_preprocessed.
  2. You can delete the static file in pub/static. Magento will auto create symlink to that file on the flight at the next request. After that you can edit main file and no need to care about static file.

When you have done any changes into Knockout file, html file or any js file it will not affect directly because when we deploy content data it will create cache data into pub/static folder after that each time magento retrieve data from pub. So whenever you apply any changes you have to apply

php bin/magento setup:upgrade

php bin/magento setup:static-content:deploy

if changes not applied even though you have to delete pub/static folder manually or apply command rm -rf pub/static

No need to apply php bin/magento cache:flush/clean' or php bin/magento setup:di:compile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.