PSI API(v5)在CRuX页面数据不足时复用源数据,如何可靠识别?
Why PSI API (v5) Falls Back to Origin CRuX Data & How to Detect It
Great question—this behavior trips up a lot of developers working with the PageSpeed Insights API. Let’s break it down clearly:
Why Does PSI Fill loadingExperience with Origin Data?
The team behind PSI designed this fallback behavior for three key reasons:
- Avoid empty or unhelpful responses: PSI’s core goal is to deliver actionable performance insights. If it returned an empty
loadingExperiencewhen page-level CRuX data was missing, developers would either get no usable data or have to handle messy edge cases that break integrations. Origin data is the next-best thing, as pages on the same domain usually share infrastructure, resources, and performance patterns. - Maintain API consistency: Keeping the response structure predictable (even when data is limited) reduces the work developers need to do to parse and use the API. You don’t have to write extra code to handle missing fields—you always get a valid
loadingExperienceobject. - Provide meaningful context: Even if it’s not page-specific, origin-level CRuX data still gives a reasonable baseline for how the page might perform in the real world. It’s better than nothing for debugging or setting performance goals.
How to Reliably Detect When Page-Level CRuX Data Is Missing?
While PSI doesn’t include an explicit "fallback used" flag in the response, there are two reliable ways to spot this scenario:
- Compare
sampleSizevalues across metrics: For each performance metric (likelargest_contentful_paintorfirst_input_delay), check thesampleSizein bothloadingExperience.metricsandoriginLoadingExperience.metrics. If the page has its own CRuX data, these numbers will differ (the page’s sample size will be smaller or unique). If they’re identical across all metrics, PSI almost certainly used origin data as a fallback. - Cross-reference
idfields with metric data: TheloadingExperience.idis a hash of the page’s full URL, whileoriginLoadingExperience.idis a hash of the domain. If the page has unique CRuX data, the metric values (likedistributionsandpercentiles) inloadingExperiencewill differ from the origin’s. If every metric matches exactly and thesampleSizevalues are the same, it’s a fallback.
Note: Full value comparison alone isn’t 100% foolproof (incredibly rare cases where a page’s data matches the origin’s exactly), but pairing it with sampleSize checks eliminates almost all false positives.
内容的提问来源于stack exchange,提问作者Aaron Peters
相关产品推荐
相关产品推荐

