Separate a restored public guide from a normal document load before comparing performance. A reader returning with the browser's Back button may receive a preserved page from the back-forward cache. Counting that return as a fresh document download can make a performance report misleading even when the visit itself is legitimate.
Define visit counting and performance classification separately. A return can be a new reading entry under the business policy while requiring a different performance clock. This procedure does not change analytics, routing or browser caching; it supplies a filled acceptance transcript for the existing measurement owner.
Use The Actual Restore Signal
The web.dev bfcache guide explains that pageshow occurs on initial loading and when a page is restored. Its persisted property is true for a bfcache restoration and false otherwise. The guide distinguishes bfcache from the HTTP cache and discusses its implications for measurement.
A normal pageshow with persisted false does not prove an uncached network transfer. A new document can still use HTTP caching. Likewise, a history-navigation label by itself is not a substitute for observing whether the page was actually restored from bfcache.
The documentation-view contract handles intentional page-view boundaries, including return navigation. Keep that business-view question separate from classification of document loading and restoration.
Freeze A Fictional Reading Journey
Consider guideA. The reporting policy counts each shown entry into A as a reading entry, whether it is a normal document load or a restoration. It keeps those performance categories separate. Events from the other page are outside this guide-specific fixture.
| Step | Observed fixture signal for A | Reading entries added | Normal document loads added | Restores added |
|---|---|---|---|---|
| Open A initially | pageshow,persisted false | 1 | 1 | 0 |
| Leave for another page | No new shown entry for A | 0 | 0 | 0 |
| Back to preserved A | pageshow,persisted true | 1 | 0 | 1 |
| Reload A | pageshow,persisted false | 1 | 1 | 0 |
| Leave and later return without restoration | pageshow,persisted false | 1 | 1 | 0 |
The result is four reading entries, three normal document loads and one restore. Those invented counts establish a bookkeeping contract, not an observation about a real site's bfcache rate. The leave step does not itself prove that the browser will preserve the document for the next return.
Execute The Classification Locally
This Python consumes normalized synthetic pageshow records. It tests the chosen counters only; it is not a browser performance library and does not send analytics events.
shown = [
{"persisted": False},
{"persisted": True},
{"persisted": False},
{"persisted": False},
]
def classify(events):
counts = {"entries": 0, "normal_loads": 0, "restores": 0}
for event in events:
assert type(event["persisted"]) is bool
counts["entries"] += 1
key = "restores" if event["persisted"] else "normal_loads"
counts[key] += 1
assert counts["entries"] == counts["normal_loads"] + counts["restores"]
return counts
assert classify(shown) == {"entries": 4, "normal_loads": 3, "restores": 1}
try:
classify([{"persisted": "false"}])
except AssertionError:
pass
else:
raise AssertionError("String flags must not become restore evidence")The string negative case matters because a generic truthiness check can treat the nonempty string “false” as true. Preserve the actual boolean rather than a loosely transformed label from an intermediate export.
Do Not Reuse The Old Load Clock
For a fictional performance example, assign the three normal loads measured durations of 900,600 and 800 milliseconds under one defined local measurement. Their arithmetic mean is 2300 divided by 3, approximately 766.7 milliseconds. These are invented values, not site benchmarks or a Core Web Vitals result.
The restoration has its own explicitly defined local interval: a restore signal at 100000 and a chosen ready marker at 100040 on the relevant preserved clock. That difference is 40 milliseconds. The ready marker is a test definition, not a universal standard metric or proof of visual completeness.
Reusing the original 900ms load measurement for the restore would describe an old observation as a new download. Using 100000ms since the original document's time origin as the restore duration would include unrelated residence away from the page. Neither answers the restoration question.
Keep Unlike Measurements Out Of One Mean
Combining 900,600,800 and 40 yields 2340 divided by 4, or 585 milliseconds. The arithmetic is correct but the summary mixes three normal-load measurements with a differently defined restoration interval. Do not report it as a single improved page-load average.
If a supported performance library supplies bfcache-aware metrics, inspect its current documented lifecycle and implementation rather than adding a second improvised measurement owner. The acceptance question is whether the actual reporting definition handles restoration correctly, not whether this local counter reproduces a field metric.
The CrUX scope review keeps page and origin evidence separate. It does not make this synthetic four-entry ledger representative of a real field population.
Test Lifecycle And State Restoration Together
Repeat the actual authorized browser journey with a representative public guide. Inspect the observed pageshow signal and the retained reader state: selected example, expanded section, scroll location or other supported context. Record what the browser actually restores rather than assuming every return uses bfcache.
Do not infer failure from an unavailable restore. Investigate eligibility and the actual navigation path through the responsible browser/performance process. Changing route architecture or access controls is outside this measurement task.
The release ledger should identify instrumentation or lifecycle-handler changes. A page can gain restore observations because measurement coverage improved, without becoming faster or more popular.
Save A Two-Layer Receipt
Keep the business-entry policy, raw restore flag, classification counters, performance timing definition, clock origin, source/library revision and actual tested environment. Use the measurement-gap method for missing lifecycle evidence rather than assigning all unknown returns to one category.
Approve when shown entries reconcile to the declared categories and performance values retain their own timing basis. The result is a trustworthy distinction between reading returns and document-load work. It does not establish a universal bfcache hit rate, a ranking improvement or a complete measure of reader satisfaction.
