This article talks about static content deploy (SCD) best practices in Magento to help avoid issues where the static content would not be available on your website.
Affected products and versions
- Magento Commerce, all versions
- Magento Open Source, all versions
- Magento Commerce Cloud, all versions
Best practices
To avoid an issue with static content not being available on your website, follow these best practices to make sure your static content is both configured and deployed correctly:
- Make sure to follow deployment guidelines:
- For Magento Commerce and Magento Open Source, all versions: Deployment Overview
- For Magento Commerce Cloud, all versions: Cloud deployment process and also Static content deployment strategies
- For Magento Commerce Cloud, all versions, ensure that ece-tools is on the newest release: Update ece-tools version
- For Magento Commerce Cloud, all versions, make sure that static content is deployed during the build phase rather than the deployment phase: Configuration management for store settings - Static content deployment performance
- Make sure that you do not have long-running cron jobs, and kill any long-running cron processes. Long-running cron jobs can take up CPU resources and potentially greatly increase deployment time.
- For Magento Commerce and Magento Open Source, all versions, check that the
php
process in CLI has access to thepub/static
directory, otherwise you could face an issue where a static content deploy will be unable to write files to that directory. For more information: File systems access permissions - Ensure the
generated
directory is not a shared directory across builds, otherwise builds could fail randomly. For more information:- Magento Commerce and Magento Open Source, all versions: Technical Details
- Magento Commerce Cloud, all versions: Deployment process - Phase 2: build
- Check your SCD strategy. The quick strategy is the default. For more information:
- Magento Commerce and Magento Open Source, all versions: Static files deployment strategies
- Magento Commerce Cloud, all versions: Deploy variables - SCD_STRATEGY