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

LCP Got Slower After a CDN Change? Diagnose Caching, Discovery and Rendering

// / / 光算科技

If LCP becomes slower after a CDN change, first confirm that the page, test conditions and LCP element are comparable. Then separate document TTFB, resource load delay, resource load duration and element render delay. Cache misses, additional connections, late discovery, a larger transformed image or blocked rendering may contribute. The fact that a CDN is present does not identify the cause.

This workflow covers caching, preload and DNS in the context of the complete request and rendering path. For the measurement basics, see our LCP, INP and CLS guide.

Make the before-and-after comparison meaningful

Save the URL, HTML and image versions, test location, device, browser, network and CPU settings, plus browser and CDN cache states separately. Repeat comparable observations and retain the distribution or median. Do not directly compare one warm-cache office visit with a remote phone's cold-cache run.

Check whether the LCP element changed. A desktop hero image may be replaced by a heading on mobile. Image, script or HTML transformations bundled with a CDN can also alter the loading path. The field section of PSI represents the preceding 28-day collection period and may fall back to origin-level data; it is not the result of the refresh you just performed.

Use the four LCP parts to choose a target

The web.dev optimization method divides LCP into these parts. Text LCP without a separately loaded resource can have zero resource-load components. Follow the measurement for the actual element rather than forcing an image waterfall onto every page.

PartWhat it coversChecks after a CDN change
Document TTFBNavigation start to the document's first byteRedirects, connections, origin processing and HTML caching
Resource load delayDocument first byte to the LCP resource starting to loadLate discovery, lazy loading, CSS/JS dependencies and priority
Resource load durationLoading the LCP resource itselfThe delivered file, connections, origin fetches, cache state and transfer size
Element render delayResource completion to the element being paintedBlocking styles, scripts, main-thread work, visibility and layout

Teaching example: suppose the four parts are 0.6, 0.8, 0.7 and 0.4 seconds, totaling 2.5 seconds. If downloading becomes 0.3 seconds faster but the element still waits for the same script to reveal it, the saved time can become render delay and total LCP can remain unchanged. These are hypothetical timings, not measurements from this website or a customer.

Inspect real cache responses, not just an account-wide hit ratio

Start with HTML, then inspect the actual LCP resource. Cached images do not establish that dynamic HTML is cached. One miss does not establish that the whole CDN is broken. Interpret HIT, MISS, BYPASS and revalidation states using that provider's documentation rather than assuming all vendors use identical fields.

For example, Cloudflare's default cache behavior distinguishes file types and is affected by responses, origin directives and configured rules. Moving a URL onto a CDN hostname does not guarantee edge storage. Check other providers against their own effective configuration and plan capabilities.

Check the conditions that change the response

  • Headers and overrides: record Cache-Control, applicable Expires and validators, and the CDN rules. Browser and shared-cache lifetimes need not be identical.
  • Cache keys: inspect the resource's actual width, crop, format, language and user-state conditions. A marketing parameter on the page URL does not automatically appear on its image URL.
  • Hits and versions: repeat the same request conditions and compare returned files. Confirm invalidation or versioning after an image update; HTML should not reference deleted files.
  • Origin paths: use logs to establish whether a specific request fetched from origin and whether the response was abnormal. A first-time browser visitor can hit an edge object already cached for someone else.

Cloudflare's cache-key guidance explains configurable key components. Consider ignoring a parameter only after establishing that it does not change the response. Do not discard dimensions, signatures, authorization or personalization simply to raise the hit ratio. Private account and transactional states require application-appropriate handling.

Under HTTP caching rules, no-cache does not prohibit storage; no-store does. Inspect freshness, validation and shared-cache eligibility together instead of interpreting one directive as proof that nothing is cached.

Find the resource early and use preload selectively

Locate the actual image request in Network and inspect its initiator, start time and priority. Images in initial HTML are usually discoverable earlier; CSS backgrounds depend on style discovery, and script-inserted images depend on code execution. If the image is the LCP candidate, remove inappropriate lazy loading and inspect what the framework really emits.

This is a teaching example for an already identified initial-viewport image. Replace its path, dimensions and description with real values:

<img src="/images/example-hero.webp"
     width="1200" height="675"
     style="width:100%;height:auto"
     fetchpriority="high"
     alt="Replace with an accurate description of the actual hero image">

fetchpriority is a hint, not an absolute scheduling command. If the resource remains hidden behind CSS or later scripts, consider making it discoverable through preload. An image already discovered promptly does not need another hint just to complete a checklist.

ResourceConfiguration to verifyCommon mistake
Imageas="image", matching URL and responsive selectionDownloading the desktop preload and then a different mobile image
Fontas="font", type and crossorigin matching the real requestPreloading unused weights or using an incompatible request mode
CSSWhether it is late-discovered and needed; the stylesheet still needs to be appliedPreloading without applying the stylesheet, or prioritizing every file

Check unused-preload warnings and duplicate requests. Select resources from dependencies and measurements, not a universal rule that three is safe and four is slow, or that a given start-time improvement guarantees a pass.

Investigate DNS and connections without adding estimates together

Inspect DNS, initial connection, TLS, queuing and request order in the waterfall. More hostnames can add preparation, but caching, parallel work and connection reuse also affect the result. Multiplying an assumed delay by the number of hostnames is not a valid measurement of page-level LCP loss.

For a critical cross-origin resource needed soon, evaluate preconnect, which prepares a connection. dns-prefetch only resolves the hostname early. Preconnecting every third party can add overhead; check whether each hint is used.

Evaluate hostname consolidation, self-hosted fonts or DNS changes against the actual deployment. CNAME depth does not imply a fixed number of additional round trips. Do not remove required provider routing records or replace them with a hard-coded edge IP. Preserve necessary analytics, consent and customer-service functions while testing a different loading strategy.

Explain why faster delivery may leave LCP unchanged

Check the file the browser actually receives, not only the uploaded original. Wrong responsive selection, oversized transformation parameters or changed content can increase work. Use image compression and visual-quality checks to retain important detail. Brotli and gzip principally help suitable text resources; applying them indiscriminately to already-compressed images is not a complete optimization.

If the resource has finished but LCP remains late, inspect styles, script execution, layout and element-visibility conditions in Performance. The LCP misconceptions guide explains how faster downloads can simply shift waiting to another part. More preload tags cannot solve every rendering delay.

Keep a deployment result that can be rechecked

  1. Verify origin and public HTML, selected images and relevant headers to establish that the CDN serves the intended version.
  2. Repeat comparable cold- and warm-condition tests. Browser Disable cache does not clear edge nodes.
  3. Record the LCP element and all four parts. Check whether image proportions or asynchronous content worsened CLS, and exercise real interactions.
  4. Monitor later field observations for the relevant devices and regions. Report a lab-only result when field samples are unavailable.

A useful conclusion identifies the changed waiting stage, whether the page still works and which user data has actually improved. CDN deployment, a faster lab LCP, a field-data pass and search-traffic growth are separate outcomes.