What are difference between developer and production mode in magento2

0
48
mode-mgento2

Magento 2 platform can be used in any of these 3 offered modes:

Production mode

  • Deployment phase on the production system; highest performance
  • Exceptions are not displayed to the user — written to logs only.
  • This mode disables static file materialization.
  • The Magento  root can have read-only permissions.

You should run Magento in Production mode once it is deployed to a production server.

Production mode provides the highest performance in Magento 2.

The most important aspect of this mode is that errors are logged to the file system and are never displayed to the user. In this mode, static view files are not created on the fly when they are requested; instead, they have to be deployed to the pub/static directory using the command-line tool. The generated pages will contain direct links to the deployed page resources.

Any changes to view files require running the deploy tool again.

Because the view files are deployed using the CLI tool, the web user does to need to have write access. The Magento pub/static directory can have read-only permissions, which is a more secure setup on a publicly accessible server.

Developer mode

  • Static file materialization is not enabled.
  • Uncaught exceptions displayed in the browser
  • Exceptions thrown in error handler, not logged
  • System logging in var/report, highly detailed.

You should use the Developer mode while you are developing customizations or extensions. The main benefit to this mode is that error messages are visible to you. It should not be used in production because of its impact on performance. In Developer mode, static view files are generated every time they are requested. They are written to the pub/static directory, but this cache is not used. This has big performance impact, but any changes a developer makes to view files are immediately visible.

Uncaught exceptions are displayed in the browser, rather than being logged. An exception is thrown whenever an event subscriber cannot be invoked.

System logging in var/report is highly detailed in this mode.

Default mode

  • Used when no other mode is specified
  • Hides exceptions from the user and writes them to log files
  • Static file materialization is enabled.
  • Not recommended / not optimized for production: caching impacts performance negatively.

As its name implies, Default mode is how the Magento software operates if not other mode is specified.

In this mode, error are logged to files in var/reports and are never shown to a user. Static view files are materialized on the fly and then cached.

In contrast to the developer mode, view file changes are not visible until the generated static view files are cleared.

Default mode is not optimized for a production environment, primarily because of the adverse performance impact of static files being materialized on the fly rather than generating and deploying them beforehand.

In other words, creating static files on the fly and caching them has a greater performance impact than generating them using the static file creation command line tool.