Cloudflare edge Worker
Verify and roll back
Run in shadow first, switch on when Aiptimise confirms, and know the ways back before you need them.
1. Check in shadow mode#
With AIPTIMISE_MODE=shadow, load two or three pages of your site. Aiptimise sees the requests within a minute and confirms back to you. Nothing on the page changes: compare the page source with the Worker route removed if you want to be sure.
2. Switch on#
The Worker adds blocks only when both switches are on: its own AIPTIMISE_MODE and your site's mode in Aiptimise. When Aiptimise confirms the shadow check, set AIPTIMISE_MODE=on and deploy that version; Aiptimise switches your site on at the same time.
3. Check a page#
Open the source of a page Aiptimise has a document for. The last thing before </body> is one or more <script type="application/ld+json"> blocks:
curl -s https://www.example.com/a-page-aiptimise-covers \
| grep -o '<script type="application/ld+json">' | wc -l- The first visit to a page in a Cloudflare data center may come before its document is cached there and go out without the blocks; load it again.
- The page still looks and behaves as before: forms, cookies, logins and redirects.
- Optional: Google's Rich Results Test on that URL detects the structured data.
Roll back#
- Ask Aiptimise to switch your site off. It takes effect everywhere within two minutes, with no change on your side.
- Set
AIPTIMISE_MODE=offand deploy the version. It takes effect within seconds, and the Worker then passes everything through without calling Aiptimise. - Deploy the previous version:
npx wrangler versions deploy <old-version-id>@100% --yes. - Remove the route (Domains & Routes). The Worker no longer runs on your site at all.
Restore any Cloudflare setting you changed if you no longer need the Worker. The Worker never caches your HTML, so nothing of it outlives the rollback.