70% of clients running Magento 2 that came to MageCloud had been operating an M2 site in Developer
mode. Unfortunately, there isn’t enough awareness about this new feature – Magento 2 Modes.
Production
mode. This mode utilizes full page caching alongside a fully built pub
folder to pull from. It is optimised to run smoothly and efficiently leading to the greatest customer experience. Production
mode is 20-30% faster than Developer
mode.
So, if you operate a Magento 2 store and are uncertain what mode your site is in, we recommend you check and verify that your live site is in Production
mode.
If you’re not a Magento geek, you may have many questions to be answered:
Let’s start with figuring out how the Magento modes differ.
One major difference between the Magento 1 and Magento 2 platforms is the introduction of development Modes. Magento 2 modes were introduced with the release of Magento 2 that reflects varying configurations of the Magento codebase, affecting site operations and performance.
Magento 1 was operated with a single state for development and production, Magento 2 now boasts 3 separate Modes: Default
, Developer
, and Production
.
Magento has three modes of operation for deployment in a development or production environment: Default
, Developer
and Production
modes. The fastest one is Production
. Default
and Developer
modes are used for debugging purposes and should never be used for a live site.
Default
– enables you to deploy the Magento application on a single server without changing any settings. However, the Default
mode is not optimized for production.Developer
– intended for the development only.Production
– intended for deployment on a production system.
And one mode for maintenance:
Maintenance
– intended to prevent access to a Magento Commerce site while it is being updated or reconfigured.
Here is a brief description of the 3 deployment modes in Magento 2. Let’s take a quick look at each of them!
As the name suggests, the Default
mode is when no other mode is specified. The Default
mode is usually used when we launch the Magento 2 site for the first time.
This mode is a hybrid of Developer
and Production
modes and appears to be intended to ramp up the time-to-launch for base Magento 2 sites due to the ability to develop without compiling code as well as a standardized set of configurations.
Default
mode, there are no main characteristics for production, that is why you need to switch to Developer
mode or Production
mode.Default
mode errors are logged in the file reports on the server. So while debugging is possible, it is not ideal for development. Default
mode to another one, it is impossible to go back to this mode, because Default
mode is not intended for the long-term use of Magento and site support, it was introduced only to help launch sites.pub/static
directory. This means that in Default
mode full page cache is not being fully utilized as the site still serves content dynamically for each request rather than drawing from the cache.Default
mode, you can deploy the Magento application on a single server without any changes in the settings.
While this can lead to a quicker time-to-launch, new modifications and maintenance will ultimately save you time in Developer
mode due to the more advanced development functionality outlined in the next section.
The mode for the developers – to do all their development tasks! The Developer
mode is intended only for development. This is the mode you should use to customise and expand Magento.
Developer
mode, it is typically disabled to speed up development testing. This in combination with the lack of a populated and utilized /pub
folder leads to exceptionally slow load times on the frontend and Magento admin. Developer
mode automatically compiles code and offers more advanced logging (in verbose) and debugging capabilities than that of Default
or Production
modes.pub/static
directory every time they’re called and are not cached.
NOTE: Use this mode whenever you are customising or extending the Magento 2’s default functionalities.
Production
mode is designed for deployment on a production system. All live sites must have Production
mode since full caching of web pages is used in Production
mode, which ensures smooth and efficient work for clients on the site.
pub
folder to pull from and is optimised to run smoothly and efficiently leading to the greatest customer experience. Production
mode as the errors are logged at the server level and never shown to the user on the frontend.Production
mode uses full page caching with a fully built pub
folder to pull from, which results in the smooth and efficient functioning of the store. If you are concerned about offering the best customer experience, you must switch your store to this mode. Production
mode is the most secure as well due to the fact that there is no symlink created for the pub/static
folder. If an unauthenticated user gets access to the pub/static
to change the data, it would only be the duplicate versions of those files, overwritten during the next static deployment!
Anytime you switch from Developer
to Production
mode two actions must first be taken:
1. Static Deploy – this populates everything in the pub/static
folder which a Production
M2 site will then build and serve content from.
2. Compilation – this takes your site’s code and merges it into bytecode which ultimately allows for the faster retrieval of classes and results in faster page load times on the frontend. This means if a malicious user were to gain access to pub/static
and make changes they would only be changing duplicate versions of those files which would be overwritten during the next static deployment.
You are not a tech person, but the business owner who wants to know the mode of his/her store? Following the steps below, you can easily check whether your site is in Production
mode or not.
- Partner With Us: Let’s discuss how MageCloud team can help to grow your eCommerce business.
Step 1.
Log into your server via SSH as the Magento file system owner.
You need an SSH client on your computer.
When connecting via SSH use this info:
Host: ssh.example.com
Username: example.com
Password: the one you chose for SSH in your Control Panel
Port: 22
NOTE: Remember to replace example.com with your own domain.
Step 2.
Navigate to the root Magento directory. Typically it’s public_html
, but not necessarily. You can always check with your hosting provider to find your site’s root.
Step 3.
Navigate to the /bin
directory within the site root.
Step 4.
Run the following command: php bin/magento deploy:mode:show
A message similar to the following displays which mode your Magento 2 site is currently using:
Current application mode: {mode}. (Note: Environment variables may override this value.)
where: {mode}
can be either Default
, Developer
or Production
OR
So, what is your website mode in the end?
If it’s a live site in the Developer
mode, it might be an issue. So, let us know if you need any Magento help with your store!
NOTE: You should not change your site’s mode directly on the live site without first testing this fully in a development environment.
Step 1.
SSH into your site’s server.
Step 2.
Navigate to the site’s root- then to the /bin
directory.
Step 3.
Run the following command: php bin/magento deploy:mode:set {mode} [-s/-skip-compilation]
where:
where:
{mode}
is a required parameter (Developer
or Production
);[-s/-skip-compilation]
is an optional parameter(it’s used for skipping the compilation when switching to the code>Developer mode).
In the command above you can use either the value Developer
or Production
mode to switch to the corresponding mode. Once you switch the site’s mode and everything works out well, you will see the following line in the console:
Enabled developer mode.
or Enabled production mode.
Now with this being so easy to do in theory, one would wonder why his/her site is not even in Production
mode. One common issue is that there is a fault somewhere in the system that breaks the site when running this command and may take some time for a developer to identify the root cause of this.
Therefore it’s common that we see that developers tend to leave it in Developer
mode, as not to have the headache of fixing the issue as it may be a deep-rooted problem that’s not so easy to solve.
The things you should consider when attempting to convert into Production
mode:
When switching to the Developer
or Production
mode, we recommend clearing the contents of the following folders (be careful not to delete the .htaccess files, they register configuration changes for each directory):
var/cache
var/di
pub/static
var/generation
var/view_preprocessed
Developer
mode optimises the website for the developer to quickly work on and deploy new changes with minimal time to see new changes on the site frontend – for example, there is no static content deployed in the cache which would allow the developer to make changes without having to run lengthy/time-consuming commands to flush the files out the browser reads, e.g. updating the website.
However, this means that the actual page load is also increased by around 20-30% due to exactly what makes it easier for a developer to see new changes: There is no static content which essentially would work as a cache for browsers not to have to load many files on the fly.
This is a huge disadvantage as we know the website is already slow and will be affecting your conversions due to users on slow connections exiting the site with it being so slow.
It must be clear that the live Magento 2 site must be in Production
mode. The earlier you switch, the better! It is easier to switch a Magento 2 site to Production
mode with less customisation.
You should now have a better understanding of the differences between the three modes for Magento 2, as well as how to verify which mode your site is using and how to change modes. Using the different modes for Magento 2 presents new opportunities during development and ultimately offers greater performance and functionality for the platform now and for the future.
Magento 2 comes equipped with various performance optimisation features. Your job is to configure them properly.
We are always looking for ways that we can help the Magento community grow, so please let us know any questions or feedback you have!
***
If you would like to know how MageCloud can assist with your Magento store, please contact us to start discussing your requirements.