When HTTP 200 contains a 404: track both statuses in a fetch pipeline

2026-12-04来源 dev.toEnglish

A URL fetcher can successfully retrieve a site’s “not found” page. Your ingestion job still needs to know that the page was missing. If you record only the outer HTTP status, that response looks like a successful import and may reach your search index. If you record only the source status, you can lose the distinction between an upstream response and a problem in your own integration.

Give the statuses different jobs

Use the fetch API status to decide whether you can parse a successful response or need to handle a provider error. Use the source status to decide whether the returned page belongs in your dataset. Keep both in the same log record, along with the provider request ID when one is available. If no source responded, leave the source status empty.

Here is one decision table for a text ingestion job. The first two rows assume the provider delivers the response from the source site.

Fetch API status Source status Ingestion action
200 200 Check the content type, then pass the text to your parser.
200 404 or 410 Record the missing page and stop. Keep the error page out of your corpus.
429 Unavailable Delay the job according to the provider’s retry guidance.
402 Unavailable Stop and alert the account owner. A retry alone cannot add credits.

A source status of 200 does not guarantee usable content. A site can send a sign-in screen or a “not found” message with 200. Check for an expected marker, such as a product identifier, article heading or stable HTML element, before you accept the page.

Keep billing out of the ingestion decision

Treat charges as a third field. With GimmePage, for example, format=json returns site_status, request_id and cost on a successful fetch. A response with outer status 200 and site_status: 404 can have a nonzero cost because the provider returned the requested page. The job still discards that page for ingestion. On an API error, record the error code and follow its retry guidance. A Retry-After header can tell your scheduler when it may try again.

This also changes how you read dashboards. Count a returned 404 under source errors and keep its cost in your spend total. Count an account-level 429 under fetch API errors. If you combine the two, you can end up changing your concurrency settings to solve broken links.

Check those cases without making paid requests

Save four small test fixtures based on the table. Give the 200/404 fixture a short HTML error page and a nonzero cost. Assert that the page stays out of the corpus, the source status stays in the log, and the cost still reaches your billing metrics. For the 429 fixture, assert that the job is delayed instead of immediately retried. Add a 200/200 fixture with a missing content marker and verify that it is also kept out of the corpus.

Oddbench builds both IP-API.io and GimmePage. This example uses GimmePage’s documented response contract. API response reference · Error and retry reference

原文:https://www.a8q9.cn/en/article/when-http-200-contains-a-404-track-both-statuses-in-a-fetch-pipeline-ec3fd0.html

相关文章