You can avoid submitting a duplicate fetch job without assuming that two similar-looking URLs mean the same thing. Start with exact-request deduplication: match the address and the options that affect what comes back. Treat broader URL normalization as a separate application decision.
I work with Oddbench, which builds GimmePage. The examples below use its fetch request options and Markdown output guide. The same approach works with any paid page-fetch service.
Keep the submitted URL intact
Repeated query parameters are legal. One application may treat the first value as active, another may use the last, and a third may collect them all. Sorting or rebuilding the query can change the request. Browser-rendered clients can also use a URL fragment to select a route in a single-page application. Keep the original URL in your job record, and pass it as the value of the fetch API’s URL parameter using your HTTP client’s normal query encoding.
Validate the URL before accepting the job, but avoid using the parser’s normalized string as the deduplication input unless you have tested those rules against your own sources. Keep the fetch service’s public-network and private-address checks in place at the request boundary.
Include the whole fetch recipe
A worker that asks for raw HTML and another that asks for Markdown need different results. Include the character limit to distinguish short excerpts from longer responses. Browser rendering and the egress region can affect which content the source returns. Resolve defaults once, then use a fixed tuple so field ordering cannot change the key. Use a scope such as your tenant or dataset ID to prevent unrelated jobs from sharing results.
function fetchJobKey(scope, recipe) { const { url, format, output, render, proxy, country, maxChars } = recipe; const parsed = new URL(url); if (!['http:', 'https:'].includes(parsed.protocol) || parsed.username || parsed.password) { throw new TypeError('Expected a public HTTP(S) URL without user info'); } return JSON.stringify([ scope, url, format, output, render, proxy, country, maxChars ]); } The example assumes the caller has normalized option names and resolved defaults. Add any header overrides or other options that change the response to the recipe if your provider supports them. Skip shared caching for authenticated or signed URLs, and avoid putting API keys or secret query parameters in logs or cache keys.
Keep coalescing separate from caching
Put a uniqueness constraint on the key for active jobs. When two workers request the same recipe concurrently, one starts the fetch and the other waits for its result. Release the active key when the job finishes or expires. Keeping a completed response is a distinct policy with its own lifetime, provenance and invalidation rules. A failed job should also leave the active set so your scheduler can decide whether to retry.
Test at least one pair of exact matches and several near matches. Reorder a repeated query parameter, change the output format, change the excerpt size and try the same recipe under two tenants. Those cases verify that your key joins identical work without merging requests whose results may differ.
Written with an AI assistant for Oddbench.

