Make the largest element on the page load faster on Cloudflare
Why it matters
Largest Contentful Paint is how long visitors wait before the main image or heading shows, and a poor value means many of them wait too long. Google counts this in its page experience signals and slow pages lose visitors.
Staged change. Do this in stages and check each one before the next, so a mistake does not break your site or your mail.
The fix
- Check that the hostname is proxied (orange cloud) in DNS. Cloudflare already caches common static files (images, css, js, fonts) by file extension, but not html. A Cache Rule under Caching, Cache Rules is only needed to set a longer Edge TTL and Browser TTL for those files (a month is a sensible start for files whose names change when their content does).
- For a WordPress site, Cloudflare's Automatic Platform Optimization (an add-on for the Free plan, included with higher plans) caches html safely for logged-out visitors. Do not use Cache Everything on pages that differ per visitor, because it can serve one visitor's page to another.
- In Speed, Settings, Content Optimization turn on Early Hints. It only has an effect when your origin sends Link headers with rel=preload or rel=preconnect for the key assets (for example the hero image or main font); the browser then starts loading them while your server is still answering. Polish (image compression and WebP or AVIF conversion, on paid plans) can shrink images that you cannot change at the source.
Cache rule expression (Caching, Cache Rules)
(http.host eq "example.com" and http.request.uri.path.extension in {"css" "js" "woff2" "avif" "webp" "png" "jpg" "jpeg" "svg"}) The examples use example.com. Replace it with your own domain.
Related
- Reported by the Core Web Vitals check
- Make the largest element on the page load faster
- Stop the page layout from jumping while it loads
- Stop the page layout from jumping while it loads
- Make the page respond faster to clicks and taps
- Make the page respond faster to clicks and taps
- Reduce the JavaScript that blocks the page while it loads
- Reduce the JavaScript that blocks the page while it loads
- Collect real-user speed data for your site
Scan your domain to see whether this applies to you.