Cloudflare Workers: publish your IndexNow key without touching your store

By Martín Garay

A Worker serves a symbolic /{key}.txt verification file beside an online store.

IndexNow verifies ownership through a file containing the key. It is usually placed at the domain root; the protocol also documents other locations using keyLocation with a specific scope. If your platform cannot serve the file, a Worker may be able to respond at that URL, provided the domain configuration allows it. Official documentation.

What a Cloudflare Worker is

Cloudflare is the network that speeds up and protects a huge part of the internet; if your store uses a custom domain, your DNS very likely goes through it already. A Worker is a mini-program that runs on Cloudflare's servers, before traffic reaches your store. You can tell it: "when someone requests exactly this URL, answer it yourself; let everything else through".

That turns the impossible problem into a trivial one: the key file doesn't need to exist on your store — Cloudflare answers it for you.

The architecture we use (and why it's key-agnostic)

A good approach is to separate two pieces: how the Worker obtains the key and which route invokes it. Looking up a current key through an API may avoid changing code when it changes, but it does not automatically update a route whose name contains the previous key.

  1. Scoped routes: configure the exact file for each expected host. A pattern such as /*.txt is invalid; a broad domain/* route includes all that traffic and needs a separate assessment.
  2. Request filter: check the file name and response; unrelated paths should keep their expected behavior.
  3. Key source: it may be a setting in the example or an API from the connector. In the latter case, check its contract, errors, and freshness. An exact route tied to the key must be changed when the key rotates. Cloudflare route patterns.

Exclusive content

For signed-in readers

A host and route map before configuration

Compare the apex, www, and exact routes to identify which requests would reach the Worker.

Sign in to access this section →

We work to offer the best possible content, which is why some of these explanations are not public.

Cost depends on plan, volume, and route scope. Review the current Workers limits and your account's usage. A broad route may invoke the Worker for requests across the store; do not assume zero cost or a particular number of visits.

Exclusive content

For signed-in readers

A sample Worker with a small contract

Review a standalone example with a fictional key and six cases for checking responses, methods, and origin pass-through.

Sign in to access this section →

We work to offer the best possible content, which is why some of these explanations are not public.

The real case that taught us DNS: A records eating your Worker

The historical case that prompted this guide showed a difference: the key responded on www, while the apex returned 404. That is a useful symptom to investigate host by host, but it does not show that every A record for a SaaS platform should be replaced.

Before changing DNS, check the values supported by the platform, the proxy, routes, and Cloudflare for SaaS behavior. Cloudflare's O2O documentation explains that two zones may be involved. Keep the previous configuration and validate the store and email too; an instant or interruption-free change is not guaranteed. The rest of the setup is in the technical guide to Cloudflare for SEO and GEO.

Exclusive content

For signed-in readers

Diagnose the apex and www separately

Use a check tree to distinguish DNS resolution, proxy, route, and content before changing records.

Sign in to access this section →

We work to offer the best possible content, which is why some of these explanations are not public.

Doing it by hand vs. guided

Everything above can be configured manually in 10-15 minutes if you're comfortable with Cloudflare (and if you're not, start with the jargon-free setup guide). IndexNow Connect turns it into a checklist: the built-in guide uses your real domain and key, shows screenshots of every Cloudflare screen (with the exact buttons), gives you the ready-to-paste snippet, diagnoses live what your domain is responding — including the A-records case — and verifies the key automatically once everything is in place.

Exclusive content

For signed-in readers

Rotate a key without losing the change map

Follow a rotation record with before-and-after checks, including updates to exact routes.

Sign in to access this section →

We work to offer the best possible content, which is why some of these explanations are not public.

Frequently asked questions

Does the Worker slow my store down?

With an exact route, the intended scope is limited to the key file. Check the actual patterns and any broader route in the zone. This guide does not present a latency measurement for your store.

Do I need a paid Cloudflare plan?

You may be able to use a free plan depending on account features and volume. Check current limits and usage; do not assume every domain or pattern has the same cost.

What happens if my IndexNow key rotates?

Review the file, sender, and routes. If the Worker looks up the current key through an API, you may not need to change its code, but an exact route containing the old name does need an update. Verify the new file before considering the rotation complete.

Does this work for any SaaS platform?

It depends on the platform, domain control, and Cloudflare configuration. Using Cloudflare for DNS alone does not prove the route will run. Check compatibility and test a sample before changing a real store.

The guide in IndexNow Connect, the CookingMetrics tool for notifying IndexNow of catalog changes, walks through this same Worker with your real domain and key, and verifies the key once it is published. Which platforms it is available for is on the IndexNow Connect product page.

Contents

Want to notify search engines when your catalog changes?

Explore IndexNow Connect