Performance, Caching, and Deployment/Configuration
Caching layers
Commerce has multiple cache types (config, layout, block_html, collections, full_page, reflection, db_ddl). Full page cache (FPC) is handled by built-in or Varnish; know that Varnish sits in front and requires a configured backend host. Cache is stored in the configured backend (file, Redis, database). Redis is recommended for default and page cache in production; session storage can also use Redis. Private content (customer-specific blocks) bypasses FPC via customer data sections and AJAX-loaded private content.
Modes and deployment
Modes: default, developer, production. Production mode enables DI compilation and static file deployment. Deployment steps include composer install, bin/magento setup:di:compile, setup:static-content:deploy, and cache flush. Know that static content deploy is locale- and theme-specific. Configuration can be split across config.php (system config) and env.php (sensitive/connection settings).
Performance practices
Use indexers, avoid N+1 queries, enable flat catalog where appropriate, use Redis for cache/session, configure Varnish for FPC, and use asynchronous operations (message queues) for heavy tasks. Profiling via built-in profiler and New Relic integration is common.
Traps
- Assuming developer mode is safe for production (it disables compilation benefits).
- Forgetting that FPC does not cache private/session content.
- Believing static content deploy is optional in production.
- Confusing env.php (infrastructure/secrets) with config.php (system config).
Rule of thumb
Production checklist: production mode, DI compiled, static content deployed, Redis for cache and sessions, Varnish for FPC, cron running, indexers on schedule. Worked example: a slow category page often stems from an invalid indexer forcing on-the-fly EAV queries; reindexing and enabling the flat/index table resolves it.