Connect CDN and WebP optimization
Connect CDN for free and get unlimited WebP image optimization for 20$ per month. WebP compression helps to make your store faster reducing image size up to 50%. Visit https://www.cloudflare.com/ for more details.
Throughout the guide replace "yourdomain.com" with the domain you are connecting to Cloudflare.
Setup for a domain hosted on Cloudflare
Open a Cloudflare account and attach billing information
Migrate DNS records to Cloudflare if the domain is not already there.
Switch NS records in the register if the domain is not already there.
Point www.yourdomain.com CNAME lb.eu.i.readymage.com (for instance created in EU region) /lb.us.i.readymage.com (for instance created in US region), proxy → yes
Point yourdomain.com CNAME lb.eu.i.readymage.com (for instance created in EU region) /lb.us.i.readymage.com (for instance created in US region), proxy → yes
Adjust Cloudflare settings according to recommended settings.
Setup for a domain hosted outside of Cloudflare
Cloudflare setup if you host your domain outside of Cloudflare and can't migrate NS records:
Open a Cloudflare account and attach billing information
Purchase Cloudflare Business Plan for 200$ for the specific domain.
Contact Cloudflare support asking to switch the account using TXT (CNAME) validation method. Cloudflare performs the switch within hours.
Cloudflare support will provide you with the DNS record that you need to add.
Add the provided DNS record to your existing DNS hosting panel and wait for Cloudflare activation.
In Cloudflare point: www.yourdomain.com CNAME lb.eu.i.readymage.com (for instance created in EU region) /lb.us.i.readymage.com (for instance created in US region), proxy → yes
In Cloudflare point: yourdomain.com CNAME lb.eu.i.readymage.com (for instance created in EU region) /lb.us.i.readymage.com (for instance created in US region), proxy → yes
In existing DNS hosting panel point: www.yourdomain.com CNAME www.yourdomain.com.cdn.cloudflare.net
In existing DNS hosting panel point: yourdomain.com CNAME yourdomain.com.cdn.cloudflare.net
Adjust Cloudflare settings according to recommended settings:
Recommended Cloudflare settings
SSL/TLS
Edge Certificates
Always Use HTTPS → On
HSTS
Enable HSTS → On
Max Age Header → 6 months
Apply HSTS policy to subdomains → Off
Preload → On
No-Sniff Header → On
Minimum TLS Version → TLS 1.2
Opportunistic Encryption → On
TLS 1.3 → On
Automatic HTTPS Rewrites → On
Security
WAF → Managed rules
Managed rules → On
Cloudflare Managed Ruleset
Cloudflare Magento → On
Cloudflare Php → On
Bots → Configure Super Bot Fight Mode
JavaScript Detections → Off (if you leave it "on", the performance will decrease slightly, but it will be possible to detect robots more accurately)
Settings
Browser Integrity Check → On
Privacy Pass Support → On
Speed
Optimization
Polish → Lossy + webP
Auto Minify → JavaScript, CSS, HTML
Brotli → On
Early Hints → On
Enhanced HTTP/2 Prioritization → On
Mirage → On
Rocket Loader → Off (You can try to enable it for sites that are not single-page applications [SPA], for example, for ScandiPWA which is a SPA site it should be disabled)
Caching
Configuration
Crawler Hints → On
Rules
Page Rules → Create Page Rule
*site.com/static/*, Browser Cache TTL: a year, Cache Level: Cache Everything, Edge Cache TTL: a year, Origin Cache Control: Off
*site.com/media/*, Browser Cache TTL: a year, Cache Level: Cache Everything, Edge Cache TTL: a year, Origin Cache Control: Off
Network
HTTP/2 → On
HTTP/2 to Origin → On
HTTP/3 (with QUIC) → On
0-RTT Connection Resumption → On
Exclude Magento admin from Cloudflare
In order to avoid Cloudflare becoming a bottleneck for long backend operations, you can exclude it from Cloudflare.
Replace admin.yourdomain.com with your Magento 2 admin URL.
Set up a separate domain for your Magento 2 admin that differs from your Magento 2 front-end domain.
Point admin.yourdomain.com CNAME lb.eu.i.readymage.com (for instance created in EU region) /lb.us.i.readymage.com (for instance created in US region), proxy → no.
Last updated