跳至正文
网站性能与 Core Web Vitals · Google SEO

CLS Increased After a CDN Change? 3 Image-Hosting Checks

// / / 光算科技

If CLS rises after a CDN change, identify the shifted elements first, then check reserved image proportions, the image variant actually delivered and other content that appears late. A CDN changes delivery. A slow image contributes to layout shift when its arrival moves visible content unexpectedly; an image with correctly reserved space can load slowly without increasing CLS.

Image hosting therefore needs more than a node-count comparison. The three checks below address layout correctness, reliable delivery of the right file and verification of the deployed result.

1. Preserve the right dimensions after image transformation

Under the current CLS definition, the score represents the largest session window of unexpected layout shifts during the page lifecycle, rather than an unlimited sum of every shift. Consecutive shifts in a window are less than one second apart, and the window lasts at most five seconds. The good target is 0.1 or less at the 75th percentile, assessed separately for mobile and desktop visits.

Check the selected file, not just the presence of width and height

  1. Inspect the image in browser developer tools. Record its selected currentSrc, intrinsic dimensions and displayed dimensions.
  2. Compare the HTML width/height and CSS aspect ratio with that resource. A 1200×800 original transformed into a square crop no longer matches a reserved 3:2 area.
  3. Test both mobile and desktop breakpoints, including picture, srcset and sizes. The default img URL may not be the resource a phone receives.
  4. Use a slow connection to inspect the image, placeholder, error fallback and caption. Check whether their appearance pushes existing text away.

The web.dev CLS optimization guide recommends reserving space for images and late components. A source element inside picture can also specify width and height, which is useful when mobile and desktop art direction uses different proportions.

This is a teaching example for a below-the-fold article image. Replace the sample paths and dimensions with real assets. The mobile image is 4:3 and the desktop image is 16:9:

<picture>
  <source media="(max-width: 600px)"
          srcset="/images/example-mobile.webp"
          width="640" height="480">
  <img src="/images/example-desktop.webp"
       width="1200" height="675"
       style="width:100%;height:auto"
       loading="lazy" decoding="async"
       alt="Replace with an accurate description of the actual image">
</picture>

Do not carry over loading="lazy" when the image is the initial viewport's LCP candidate. Test the actual output at each breakpoint. Correct image attributes alone do not establish that the whole page passes CLS.

2. Deliver the correct file reliably to the intended audience

Compare hosting options using the same page, image version and comparable conditions in relevant regions. Record status codes, redirects, connection setup, first byte, download time and file content. An IP lookup alone does not establish which edge location served a user, and a provider's total node count does not establish your page's speed.

CapabilityWhat to inspectWhy it matters for layout
Resizing and croppingReturned dimensions for each requested width, format and device conditionThe transformed image must match its reserved area
Cache keys and versionsWhether content-changing dimensions, crops and formats remain distinctA phone must not receive an incompatible or old crop
Failures and fallbacksWhat is displayed after a 403, 404, timeout or unsupported formatA placeholder should not unexpectedly collapse or change height
Regional availabilityRepeated observations, error records and the provider's service scopeFewer failure cases help reliability; availability is not a CLS measurement

Browser caching and shared CDN caching are separate layers. Check the actual response and effective rules against HTTP caching guidance. In particular, no-cache permits storage but requires validation before reuse; it does not mean no-store. Choose expiry and invalidation together rather than extending every image's lifetime indiscriminately.

When choosing WebP and other image compression options, inspect text, edges and transparency in each asset. A smaller file is not automatically a clearer source image or a stable page. If the main issue is a hero image appearing late, use the CDN and LCP troubleshooting workflow.

3. Locate the shift and verify the deployed version

Record loading and subsequent reading in DevTools Performance. Inspect the timing and affected nodes in the layout-shift records. A highlighted paragraph may be the content that moved, while the cause is an image, advertisement, notification or font change above it.

Save the original trace, then address the observed cause: correct the image ratio, reserve a component's space or improve font fallback. Hiding necessary content or deleting chat, consent and analytics functionality does not constitute a complete performance fix.

  • Separate cold and warm conditions. Disabling browser cache does not clear the CDN's cache. Record the actual hit state.
  • Follow a reading journey. Scroll, wait for deferred modules and operate relevant controls. Zero CLS during initial load does not prove zero shifts later.
  • Check version consistency. Origin HTML, new images, CDN responses and the browser-selected files should belong to the same deployment.
  • Follow field data. PSI reports CrUX observations when enough samples exist. Missing data must not be reported as proof that real users experience no shifts.

PSI's documentation distinguishes historical real-user data from the current lab diagnosis. Use traces to locate causes, then monitor the relevant device and collection window. Our LCP, INP and CLS guide explains the wider measurement workflow. Choose image hosting on correct delivery, stable layout and results you can recheck.