Orange Book
CDN and web performance

13 · Static assets and frontend loading optimization

Optimize build output, compression, Early Hints, images, and browser waterfalls instead of attributing every performance problem to cache.

Edited and verified by Orange Book Editorial Team ·

CDN · PHASE 5INTERMEDIATEAbout 30 minutesCompression · Early Hints · Images

Outcome

JS, CSS, and fonts use content hashes and correct cache headers; compressible text follows client capabilities; the LCP image has a suitable size and format; and only genuinely critical resources enter preload or Early Hints. The browser waterfall explains where each gain came from.

Optimization order matters more than the number of toggles

LayerFix firstWhat Cloudflare can add
BuildRemove unused dependencies, split code, content-hash filesA long CDN TTL cannot shrink an oversized bundle
HTML discoveryPrioritize critical CSS, fonts, and LCP imageEarly Hints sends preload/preconnect in a 103
TransferCompress text and reuse connectionsGzip/Brotli/Zstandard plus HTTP/2/3
ImagesCorrect dimensions, srcset/sizes, modern formatsPolish or Images transformations
RuntimeReduce main-thread blocking and third-party scriptsNetwork optimization cannot fix expensive JavaScript execution

Establish releasable asset structure

/assets/app.9f1a.js       New URL when content changes; long cache
/assets/site.6b2c.css     New URL when content changes; long cache
/images/hero-1280.avif    Generated for its real display size
/                        Mutable HTML; conservative Browser TTL

Fingerprinted files fit public, max-age=31536000, immutable. HTML still needs a short Browser TTL and targeted invalidation on release. Do not cache a multi-megabyte, unsplit JavaScript bundle forever and call the frontend optimized.

Verify content compression

Cloudflare can currently deliver Gzip, Brotli, or Zstandard to visitors. The result depends on client Accept-Encoding, the zone plan's default, and matching Compression Rules. Never infer the algorithm from a dashboard toggle alone.

curl -sS -D - -o /dev/null \
  -H 'Accept-Encoding: zstd, br, gzip' \
  https://www.example.com/assets/app.9f1a.js

Inspect Content-Encoding, Content-Type, Vary, and transferred bytes. Compare requests with and without compression. Very small responses, unsupported content types, and status codes outside the supported set may remain uncompressed.

no-transform is an integrity control, not a free optimization

Origin Cache-Control: no-transform prevents Cloudflare from changing compression and can preserve origin Content-Length, but it also blocks optimizations that need to modify response bytes. Use it only for signatures, Range semantics, strict byte identity, or an actual length requirement.

Use Early Hints selectively

While the origin prepares a main response, Early Hints can send a 103 with Link so an HTTP/2 or HTTP/3 browser starts preload/preconnect work. It is currently available on every plan, but the page must provide useful Link headers.

Link: </assets/site.6b2c.css>; rel=preload; as=style
Link: </images/hero-1280.avif>; rel=preload; as=image

Select two or three critical resources from the waterfall

Choose only render-blocking CSS, a stable font, or the actual LCP image. Preloading every image and chunk competes for bandwidth and can make the page worse.

Make URL, as, cross-origin attributes, and the final response agree. Verify the Link on a normal 200 first, then enable Early Hints under Speed → Settings → Content Optimization.

Inspect 103 and the final page

Use a compatible browser or WebPageTest to inspect Early Hints and resource start time. Cloudflare generates hints only for qualifying HTML URIs and 200/301/302 responses. If the main headers arrive first, there may be no reason to send a 103.

Audit authenticated pages

The Early Hints cache key ignores query strings, and a cached Link can be emitted before a final 403. Never reveal private filenames, one-time downloads, or user resources in the Link. Disable the optimization on authentication paths when uncertain.

Choose one image-optimization path

PathGood fitPlan and cost boundary
Build-time AVIF/WebP + srcsetStatic sites with known image setsMost controllable; no runtime-variant fee
PolishOptimize origin images without changing URLsCurrently Pro / Business / Enterprise
Cloudflare Images transformationsURL-driven crop, resize, and format=autoFree currently includes 5,000 unique transformations/month; new variants return 9422 beyond it; paid usage is metered

Do not stack lossy CMS compression, Polish Lossy, and Images transformations on the same image. Do not lazy-load the LCP image. Other images can lazy-load, and every image needs dimensions or a stable aspect ratio to prevent CLS.

Before-and-after checklist

  • Fix URL, region, device, and network conditions; take at least three cold and warm samples.
  • Save transfer size, start time, protocol, and cache status for HTML, JS, CSS, fonts, and the LCP image.
  • Inspect LCP, INP, and CLS instead of only a Lighthouse score.
  • Enable one Compression Rule, Early Hints change, or image path at a time.
  • Roll back the changed item if benefit is absent or errors rise; do not simultaneously disable HTTP/3, cache, and TLS.

If the slow path is primarily uncacheable, continue with dynamic content and Argo Smart Routing.

Primary sources

Did this page help you complete your goal?

Beta feedback is generated in this browser and is never uploaded automatically.

On this page