Minimize Magento downtime when deploying changes in production mode

Here are a few suggestions to minimize downtime on Magento, whenever you need to deploy changes in production mode.

Changes on phtml template files in the child theme
(no downtime)

All templates are updated in folder var/view_processed (no need to delete it first)

bin/magento s:s:d -j 4 -t <Theme_Vendor>/<Theme_Name>
bin/magento c:f

Changes in less, css, js files in the child theme
(no downtime if css and js are served from cache while redeploying)

Previous files need to be delete prior to the redeploy. Otherwise they are not updated.

rm var/view_preprocessed/pub/static/frontend/<Theme_Vendor>/<Theme_Name>/ -rf
rm pub/static/frontend/<Theme_Vendor>/<Theme_Name>/ -rf
bin/magento s:s:d -j 4 -t <Theme_Vendor>/<Theme_Name>
bin/magento c:f

Changes that require database update – modules updates
(with downtime)

You can check if these commands are needed by running bin/magento setup:db:status.

bin/magento s:up
bin/magento s:d:c
bin/magento s:s:d -j 4 -t <Theme_Vendor>/<Theme_Name>
bin/magento c:f

Changes on module php code (with DI changes)
(no downtime although glitches might occur while code is being compiled)

Code within generated folder is recompiled (no need to delete it first).

bin/magento s:d:c
bin/magento c:f

Leave a Reply

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