# Real Browser Error Detection (external runner)

On your own trusted computer or CI runner (Node.js 20+):

```sh
cd wp-content/plugins/indiatvdna-turbo-cache/tools/browser-audit
npm install
npx playwright install chromium
node audit.cjs https://your-wordpress-site.example/ --output browser-report.json
```

Open **Turbo Cache Pro → Verification Lab** and paste the resulting JSON.
This is a **read-only** smoke test of homepage, search results, wp-login.php, and /checkout/ at mobile and desktop viewport sizes. It captures JavaScript errors, asset HTTP failures, menu-button interactions, synthetic TTFB/LCP/CLS and interaction-event timing when measurable. No login, order, payment, user account changes or form submission is attempted. On a shop with a different checkout slug, adapt the scenarios on your local runner; don't submit orders.

Not every page necessarily exists. WARNING is not a verified failure. Real-user INP and CPU consumption require production monitoring; synthetic browser INP is **not field CWV**. Never place site credentials or personal user data in the report. Import reports only from trusted testing environments; imports are labelled external evidence, not cryptographically authenticated.

## Optional visual & performance regression check (v1.3.40)

Use this on a **staging** environment with identical fixture content, browser version,
viewport and network where possible. No credentials, cart purchases or form submissions:

```sh
node audit.cjs https://staging.example/ --output before.json --screenshots ./screenshots-before
# Change one optimization on staging, purge/regenerate cache, then rerun.
node audit.cjs https://staging.example/ --output after.json --screenshots ./screenshots-after --compare-screenshots ./screenshots-before --visual-threshold 0.025
node compare.cjs before.json after.json --output comparison.json
```

Screenshot comparison is optional. A pixel difference above 2.5% yields `WARNING`
(review manually: ads, rotating content and font rasterization may cause noise).
The comparator flags major measured synthetic timing deltas and functional failures.
Screenshots stay on your computer and are **not** embedded in WordPress reports.
Long-task duration is an approximate browser-observed total, not server CPU time.
These are **one-shot smoke tests**, not statistically representative benchmarks;
run multiple controlled trials before attributing performance changes.
Never put credentials or private screenshots in report uploads. No automation
will rollback production settings based solely on an imported browser report.

## v1.3.41 measured speed verification (read-only)

```sh
# Check public-page delivery evidence from Cache-Control/CF/LiteSpeed/cache HIT headers.
node cache-probe.cjs https://staging.example/ --count 3 --output cache-report.json
# After three comparable baseline and three changed staging runs:
node recommend.cjs --before b1.json b2.json b3.json --after a1.json a2.json a3.json --output advice.json
```

The cache probe measures complete HTTP response time, *not* TTFB, CPU usage or field CWV. A missing cache HIT header is **NOT VERIFIED**, not proof of a MISS. It does not follow redirects or send cookies. Run on an anonymous public HTML URL only.

The browser audit now records observed JS/CSS network transfer KB, LCP element type and a limited allowlist of cache-response headers. Transfer sizes may be zero for cross-origin resources, memory-cached assets or entries with restricted timing access; they are not a complete byte budget. The offline recommendation requires at least three comparable browser runs before and after **one manual change on staging**. It never alters WordPress settings, deploys profiles or initiates production rollback. A result is a candidate for further canary review, not a guarantee of speed improvement.

## v1.3.42: cache layer A/B comparison (read-only)

```sh
node cache-probe.cjs https://staging.example/ --count 3 --output cache-before.json
# On staging, change ONE optimization manually and purge/warm its cache.
node cache-probe.cjs https://staging.example/ --count 3 --output cache-after.json
node compare-cache.cjs cache-before.json cache-after.json --output cache-comparison.json
```

The comparator requires two successful reports for the **exact same public URL**, at least
three requests per report and at least two HIT-evidenced responses per report. It reports
per-layer full-response timing medians. It does **not** measure PHP CPU, TTFB, field Core
Web Vitals, or automatically select a server cache owner. Errors/redirects and missing HIT
evidence produce an explicit incomplete result instead of a false claim of improvement.

`recommend.cjs` now requires matching device/scenario/**URL** coverage with no duplicate
cases, and declines optimization recommendations if a baseline or candidate browser test
contains `WARNING`, `FAIL`, or unexpected HTTP status. These tools cannot modify WordPress
settings and belong on staging or a controlled test environment.
