Two installations
- In a Worker you already run on the site: add the library’s two lines where it fetches and
returns the page (Quickstart, step 4). Keep its routes;
scopelimits doubleshift to your sections. - In a dedicated Worker whose routes cover your sections only. A request runs only the Worker of the most specific matching route, so such a route takes those paths away from a Worker already on the site: in that case, use the first installation.
Routes and scope
Cloudflare routes decide when the Worker runs.scope decides what doubleshift does once it runs
(scope). Out of scope, the Worker still runs and fetches your origin,
prepareOriginRequest still drops an agent’s conditional headers, and Cloudflare still logs the
invocation: only the doubleshift call, record and sending are skipped.
The two grammars are not equivalent. From Cloudflare’s
Workers Routes:
Give every hostname that serves articles a route; the Worker’s
fetch to the request’s own URL then
reaches your origin. The safe combination is a broad route, your-domain.example/*, and a precise
scope. To limit a dedicated Worker to a section, end its route with * after the section name,
your-domain.example/articles*, and keep scope: { include: ["/articles/*"] } to leave out
/articles-other. Keep every path of scope inside the routes: a page no route matches never reaches
the Worker.
Several sites
One Worker can carry the routes of several sites of the same account, with the same key and the samepartnerId: the library builds page_url from each request’s own host. Register each site first,
one form per domain (its www. or bare alias finds it); a host that matches no site gets no card.
scope is a list of paths, not a hostname filter: its paths apply to every host the Worker serves.
Give each host its own configuration:
One scope per host
canonicalOrigin only when the Worker answers on another host than the public one, such as a
mirror; it takes one origin, so that Worker serves one site. scope still reads the path the Worker
receives.
Direct delivery logs
Optional: cards work without this. With a logs token, the Worker also sends each delivery record to doubleshift. What each way of sending gives you, and the setup steps, are in Delivery logs.Update the library
The current version is1.1.4, SHA-256 d4db890cbf27a2da1977d3ba76e0585ab3bf7cc78111eaddc71019527114e9d1. To update, download the file
again, check that its SHA-256 matches, commit it and redeploy. A copy you do not update keeps
working, except that a copy older than 1.1.4 ignores scope. What each version changed is in the
changelog.
Rolling back to a copy older than 1.1.4, or removing scope, widens doubleshift to every page your
routes reach. To keep the perimeter, roll back to 1.1.4 or later with the same scope, or narrow the
routes first.
Watch the Worker’s records
scope as an AI agent while the tail is open: the library writes one
doubleshift_edge record per agent page in scope, none outside it. Every outcome and field is in the edge library reference.
A no_fill only says that the API answered 204, nothing to insert; its cause and the fix for each
outcome are in Verify and troubleshoot.
