Skip to content

Menu

Distinguish extractor reuse from response caching

Learn when Scraipe reuses an extractor or a cached response, why forceBrowser can return a placeholder, and how to test a fresh render without forcing compilation.

By Codex. Checked 2026-11-11.

Reuse the extraction logic, not yesterday's answer

Extractor reuse and response caching save different work. A reusable extractor applies saved selection and transformation rules to a fetched page. A response cache returns previously extracted data without running those rules on a newly fetched body. The returned JSON can be identical in both cases, so matching values alone do not tell you which happened.

In Scraipe, inspect the reported meta.tier, request options and replay context together. Use noCache: true when a new diagnostic operation should bypass the stored response while still allowing extractor reuse. Use forceCompile: true only when you intend to rebuild the extraction logic. Neither flag proves that the source's business data is current or correct.

This guide includes an eight-scenario local pipeline experiment and a downloadable comparison tool. The experiment ran the repository's actual pipeline, store and selector interpreter on invented HTML, with network and model calls replaced by test doubles. It is not a hosted API run, customer incident or speed benchmark. The tool and examples were tested with Node 22.23.2 on 30 October 2026.

Identify which work was reused

For a successful single-page scrape, these current tier names describe different paths:

Reported tierWhat the path reusesWhat to check next
cacheA stored extracted resultCache policy and whether the request was a replay
conditionalA stored result after an HTTP 304 validation responseOrigin validators and the scope of the captured representation
compiledAn existing extractor applied to the fetched pageReturned values, source coverage and network charges
compiled-freshNewly compiled extraction rulesThe new rules and the reported compile charge
healedRepaired extraction rulesThe source change and whether the repair recovered the intended fields
llmModel extraction rather than a successful reusable-selector pathFull-result validation and the reported charge

A mixed batch or crawl summary needs per-page analysis. Do not assign it one of the single-page meanings. Unknown tier names should remain unknown until you check the current API reference.

An HTTP 304 is also distinct from a cache hit that made no origin request. A conditional request asks the origin to validate its stored representation using a validator such as an ETag. A 304 allows reuse without transferring a new response body. It is not evidence that the source's prices, inventory or statements reflect external reality. The HTTP 304 reference explains that protocol behavior.

Why a browser request can return a cached placeholder

Suppose the stock field says Checking stock in the original HTML, but the page displays Ready for pickup after JavaScript runs. You set forceBrowser: true and still get the placeholder. Check the replay header first, then look at meta.tier. On a new single-page scrape, Scraipe checks the response cache before choosing how to fetch the page. If the tier is cache, the browser option never reaches the fetcher.

For a rendering diagnostic, submit a new POST /v1/scrape operation against a page you have permission to test. Replace the example URL and use the same field selection as the original request. If you use idempotency keys, give this operation a new key.

json

{
  "url": "https://catalog.example/pickup",
  "fields": ["stock"],
  "noCache": true,
  "forceBrowser": true
}

We tested that combination on a small stock-page fixture. Chromium executed the page script on loopback. We then gave the repository pipeline the original HTML or the captured DOM according to the option received by a substitute fetcher. A deterministic compiler supplied one selector for the stock field. Here is what happened at the same URL with the same schema, in order.

Request optionsResult tierStock valueFetch callsCompiler calls
Defaults, cold startcompiled-freshChecking stock11
forceBrowsercacheChecking stock00
noCache and forceBrowsercompiledReady for pickup10
Defaults againcacheReady for pickup00

The third request kept the working selector and changed the HTML it saw. The fourth returned that newly stored value. To reproduce the comparison offline, save the two captured responses beside the comparison script and run the command below.

bash

node compare-extraction-pair.mjs render-cache-pair.json

The output reports before.reportedTier = "cache", after.reportedTier = "compiled" and dataChanged = true. The fixture verifies option ordering and selector reuse. On a real page, an unchanged placeholder after a new browser fetch calls for inspecting the rendered field and when its value becomes available. A matching selector can still read a loading message. The receipt alone cannot establish stock availability.

Observe changed data without recompiling

The local experiment starts with one invented product whose title is Invented edition A. It then changes the source HTML to Invented edition B while preserving the element structure. The schema requires one string field, and the test compiler returns a deterministic selector for that field.

StepRequest or fixture changeReported tierReturned titleMock fetch callsMock compiler calls
1First request, no stored extractorcompiled-freshInvented edition A11
2Source changes to B; default requestcacheInvented edition A00
3Same URL with noCache: truecompiledInvented edition B10
4Default request after step 3cacheInvented edition B00
5Different URL with the same layoutcompiledInvented second product10
6Stored entry expired; mock origin returns 304conditionalInvented edition B10
7Same URL with forceCompile: truecompiled-freshInvented edition B11
8noCache: true on another host with no extractorcompiled-freshInvented cold product11

These are observed counts from the local test doubles, not production request-count or latency guarantees. Real fetching can involve retries, redirects or rendering. Compilation tokens in the downloadable observations are synthetic values supplied by the stub; no model was contacted and no account was charged.

Step 3 is the central distinction: the data changed without a new compiler call. Step 4 also shows that noCache is not a “never store this result” policy. The current pipeline skips the cache read, runs extraction and may populate the result cache afterward. Step 8 shows that bypassing the response cache does not promise a free compilation: a missing or unusable extractor can still require model work.

The experiment deliberately expires its local entry to exercise the 304 path. It does not measure the hosted cache lifetime. The repository has a configurable default lifetime, but this guide does not assume that configuration is the same in every deployment.

Run a live loopback cache experiment

You can now reproduce cache hits and HTTP revalidation with a server running entirely on your own computer. Download these four files into one directory:

Use Node 22; there are no npm dependencies or API keys:

bash

node --test run-lab.test.mjs
node run-lab.mjs

The lab opens an ephemeral port on 127.0.0.1, serves an invented JSON product, performs real local HTTP requests, and closes its server before exiting. It accepts no target URL or command-line options. The Node HTTP documentation describes the server APIs it uses. Execution contacts no public website, Scraipe account or model and incurs no extraction credits. On macOS, run shasum -a 256 -c SHA256SUMS to check all three payload files.

This is a deliberately small teaching model with one resource, one deterministic transformation and one response-cache slot. Building its “extractor” means constructing a JavaScript function that selects catalog.title from the JSON source. It does not infer selectors from HTML or call a compiler model. The earlier eight-scenario table exercises repository pipeline code with mocked network/compiler calls; this downloadable lab separately exercises actual loopback HTTP and its own cache model. Neither is an authenticated hosted extraction test.

The fourteen tests pass. The experiment prints seven checked results:

StepLocal operationPathReturned titleHTTP requestsFunction buildsFunction runs
1First requestbuilt-extractorEdition A111
2Origin changes to B; default requestcached-responseEdition A000
3Bypass the response cachereused-extractorEdition B101
4Default request after bypasscached-responseEdition B000
5Expire the cache; origin remains Brevalidated-responseEdition B100
6Origin changes to C; expire cache againreused-extractorEdition C101
7Explicitly rebuild the functionbuilt-extractorEdition C111

These path names belong to the lab. They are not Scraipe response tiers. Each count is the observed delta for that step; the complete report totals five HTTP requests, two function builds and four function executions. The runner checks all seven expected result tuples and the aggregate counters before printing success. An assertion, network or fixture error exits nonzero. The report includes the Node runtime and the experiment's scope.

Step 5 sends the previously stored ETag in If-None-Match. The loopback server returns an actual 304 with no new response body, and the model reuses its stored extracted data without executing the function. Step 6 sends an old validator after the origin changes; the server returns 200 with a new body, and the existing function extracts Edition C. A cached response in steps 2 or 4 makes no HTTP request at all. In the JSON report, httpStatus: null means that no request was made, not that the server returned a special status.

The lab uses a 1,000 ms cache lifetime with a manually advanced logical clock. It does not wait for wall-clock expiry and says nothing about the hosted cache TTL or latency. The controls bypassCache and rebuild are local lab options, not Scraipe request fields. Bypass skips a stored answer and its validator, reuses the function when available, and stores the new result. A cold bypass can still build the function. Rebuild fetches without a conditional validator and constructs the function again.

Failure tests cover HTTP 503, malformed JSON, a missing source field and an unsolicited 304 with no usable conditional cache. These failures preserve the prior cache entry rather than replacing it with invalid output. The lab throws the failure to its caller; it does not automatically serve stale data as a successful fresh result. Tests also check that mutating returned data cannot corrupt the stored result and that server cleanup rejects later requests.

This is not a complete HTTP cache implementation: it does not model Cache-Control/Vary policies, authorization, shared tenants, concurrency, retries, redirects, rendering, pagination, idempotency or billing. Its unchanged shape cannot establish that a source value is correct. Use the experiment to understand which work each layer saves, then use your real receipt, source evidence and consumer validation for a production decision. If the extraction rules stop matching, follow the layout-change investigation workflow rather than treating cache bypass as a repair.

Run the saved-response comparison

Download these five files into one directory:

Use Node 22 or later. There are no npm dependencies, API keys or network calls in the comparison:

bash

node --test compare-extraction-pair.test.mjs
node compare-extraction-pair.mjs reuse-cache.fixture.json

The first command passes sixteen tests using Node's built-in test runner. The second audits the saved outputs from steps 2 and 3; it does not rerun the Scraipe pipeline. Its full report includes data digests and these conclusions:

json

{
  "status": "comparable",
  "before": { "reportedTier": "cache", "reportedPath": "stored-response" },
  "after": { "reportedTier": "compiled", "reportedPath": "extractor-reuse" },
  "dataChanged": true,
  "freshness": "not-established",
  "issues": []
}

The displayed JSON is an excerpt. The complete output also keeps replay status, token observations and origin-request observations separate. With no HTTP replay header captured, replay remains null and pathScope explicitly says that it is interpreting the body claim.

The checksum file covers the four payload files. On macOS, run shasum -a 256 -c SHA256SUMS after downloading them. The observations file records the invented inputs, request flags, expected outcomes and actual local outcomes, so the experiment's boundaries remain visible beside its results.

Compare your own captures without guessing freshness

The comparison accepts a JSON object containing before and after. Each has a body with the saved response and an optional headers object containing saved response headers as strings:

json

{
  "before": {
    "headers": {},
    "body": {
      "ok": true,
      "data": [{ "title": "Earlier observed title" }],
      "truncated": false,
      "cursor": null,
      "meta": { "tier": "cache" }
    }
  },
  "after": {
    "headers": {},
    "body": {
      "ok": true,
      "data": [{ "title": "Later observed title" }],
      "truncated": false,
      "cursor": null,
      "meta": { "tier": "compiled" }
    }
  }
}

These are the tool's wrapper keys, not a Scraipe request body. Before comparing real captures, check that URL, requested fields/schema, source credentials, country and intended record window are comparable. The tool does not validate that request identity. A complete response for one page also does not prove complete website coverage.

The tool compares the data values after sorting JSON object keys; it preserves array order and distinguishes null from an absent property. Equal digests mean equal normalized captured values, not the same extractor, source revision or execution path. Different values may result from a changed page, a changed query, changed selection or errors. The tool deliberately never declares either response fresh or correct.

It reports needs-review for errors, missing data, unknown/aggregate tiers, malformed replay headers and truncated or unspecified result windows. It does not turn those conditions into successful empty results. Exit codes are 0 for a structurally comparable pair, 1 when the pair needs review, and 2 for invalid arguments or unreadable/invalid input. The file limit is 1 MiB; data nested beyond forty levels is rejected. This is a small-capture diagnostic, not a streaming validator or complete API-schema checker.

The report does not echo extracted values. Treat the capture and its digests as potentially sensitive anyway: use only necessary response fields, keep private data out of shared evidence, and never include request Authorization headers, cookies or API keys.

Separate diagnostic requests from idempotent retries

A successful idempotent replay returns the original body. If its original tier was compiled, seeing that tier again does not prove that the retry fetched another page or ran the extractor again. The comparison recognizes X-Scraipe-Idempotent-Replay: true, reports responsePath: "idempotent-replay", and preserves the original reported tier separately. Missing replay context remains unknown.

Use the same idempotency key and unchanged body to recover one original operation. To investigate a newly changed source or different cache option, create a deliberately new operation with a new key. Changing the request body while reusing the old key can conflict. Retrying the old successful operation cannot establish newer source data. See the request-receipt guide for the current replay and charge-accounting details.

Choose the smallest necessary refresh

Start with the receipt and your actual consumer requirement. If the values look old but the selector logic still fits, a separate noCache: true operation can bypass the stored response while retaining a useful extractor. If fields are misselected, reproduce the mismatch, validate the source and investigate repair or explicit recompilation. Do not repeatedly force compilation merely because unchanged data feels suspicious.

The result cache and extractor registry also have different identities. The current result key includes URL, structural schema identity and an explicitly selected egress country; reusable extractors are located by host, schema and compatible layout variants. That is why one site's compatible pages can share extraction rules while returning different data. Do not assume arbitrary pages or schemas share one extractor. Caller-supplied source credentials bypass the shared response cache; a Scraipe API authentication key is a different credential.

Read meta.credits.compile, meta.credits.egress and meta.credits.total before describing cost. Reusing an extractor can avoid a compile credit while a residential fetch still costs network credits. A new compilation or repair can be billable. Zero tokens, fast responses and equal data are each insufficient evidence for a cache hit or a zero total charge.

Finally, apply your own full-result schema validation and source checks. Use the playground for a small permitted investigation, retain the sanitized receipt and stop on unexplained differences. The local experiment proves specific pipeline behavior under controlled inputs; it does not replace verification of your hosted request, page completeness or business facts.

Sources and verification

Try the next step

Try the playground

Continue building