Skip to content

Staging redirect leftovers: old 301s cached in browsers and at the Cloudflare edge

A staging redirect after launch usually persists because a cached 301 keeps replaying in browsers and at the Cloudflare edge. Find every remaining source, purge the edge in the right order, and point the old host at production.

Your new site is live, yet some visitors still land on the staging URL or the old coming-soon page. In most cases that redirect is a cached copy of an old 301, the status code for a permanent redirect. Browsers store a 301 and follow it again without asking the network. The Cloudflare edge, the servers between your visitors and your origin, can also keep serving a cached 301 after you delete the rule that made it. The fix works in a set order. First remove every rule, server setting or plugin that still issues the redirect. Then purge the Cloudflare cache. Last, because you cannot clear a visitor’s browser, keep the staging host online and make it redirect to production.

What’s happening

Who can hand a visitor the stale redirect, in order: the browser cache answers first — a stored 301 replays instantly with no request on the wire, which is why one person sees the bug and your curl test does not. The Cloudflare edge answers next — redirect responses can be cached like any other cacheable response, so a 301 created during the migration window can outlive its rule. Then come the live issuers: edge rules someone forgot (a Redirect Rule, a Bulk Redirect entry, a legacy Page Rule, a Worker), the origin (an .htaccess line from the coming-soon phase), and the CMS (a redirect plugin still holding launch-day entries). And outside your infrastructure entirely, search engines remember the redirect mapping until they recrawl, so old SERP entries keep sending people through the stale path.

The trap is fixing these out of order. Purge the edge while a forgotten rule still issues the 301 and the cache simply refills; delete the rule but skip the purge and the edge keeps serving the cached copy.

What to check first

  • Is the redirect live or replayed? Curl is cache-free: if curl gets a 200 but a browser redirects, it is that browser’s cache. If curl gets the 301, read cf-cache-status to see whether the edge cached it or something issued it fresh.
  • Inventory every issuer that existed during the migration: Redirect Rules, Bulk Redirect lists, Page Rules, Workers on the route, origin rewrites, CMS redirect plugins.
  • Only some users affected? That is the signature of browser-cached 301s, not a live rule.

How to verify

Ask for the URL fresh, with the headers that attribute the answer:

curl -sIL https://example.com/ | grep -iE 'HTTP/|location|cf-cache-status|age|cache-control'

Read it like this: a 301 with cf-cache-status: HIT and a non-zero age is a cached copy at the edge — the issuer may already be gone. A 301 with cf-cache-status: DYNAMIC or no cache status is being generated right now by a rule, the origin, or the CMS — the inventory is not done. Then attribute a live issuer:

curl -sI https://example.com/ | grep -iE 'HTTP/|location|server|cf-ray|x-redirect-by'

server: cloudflare with a cf-ray and no cache status points at an edge rule; x-redirect-by names a CMS. Check the origin directly, since coming-soon .htaccess lines love to survive launches (-k for an Origin CA certificate):

curl -skI --resolve example.com:443:203.0.113.10 https://example.com/ | grep -iE 'HTTP/|location'

A quick edge-cache litmus test: enable Development Mode for a few minutes — it bypasses edge caching, so if the redirect vanishes while it is on, a cached copy was your problem.

The fix

  1. Remove every remaining issuer first. Walk the inventory: Rules (Redirect Rules and Bulk Redirect lists), legacy Page Rules, Workers routes, the origin’s .htaccess and vhost, and the CMS redirect plugin. Do not purge anything until this pass is complete, or the cache refills behind you; the rule-cleanup side is covered under Rules.
  2. Purge the edge. Purge the affected URLs by single-file purge, or purge everything as part of the cutover if the site is small enough to re-warm. Which purge to use and when is the subject of cache purge strategies.
  3. Make the stale destination correct itself. You cannot purge a visitor’s browser. What you can do: keep staging.example.com (or the old coming-soon host) alive and give it a 301 to production. Browsers replaying the cached hop then land somewhere correct — one extra hop for those users, zero support tickets.
  4. Tell affected reporters the short version. A private window or a cleared cache proves the fix on their machine; there is no server-side action that reaches into their browser.
  5. Re-run the chain audit. Every entry variant should now resolve in at most one hop, with no staging hostname anywhere in the location headers.

When this fix is wrong

  • The 301 is DYNAMIC every time. Nothing is cached — a live issuer is still standing and purging is wasted motion. Go back to the inventory.
  • DNS still points some resolvers at the old infrastructure. That is propagation, not redirect caching; the cf-ray will be missing or the IP will be wrong.
  • Search results still show the staging URL but clicking lands correctly. That is index lag, resolved by recrawling and sitemaps, not by anything cache-related.

Common mistakes

  • Purging before deleting the rule, then concluding purge “did not work” as the cache refills.
  • Using 301 for staging and coming-soon redirects in the first place. Permanent means permanent to every cache on the internet.
  • Testing with the launch team’s browsers — the exact machines most saturated with cached staging 301s.
  • Deleting the staging zone or hostname immediately, dead-ending every cached bookmark and remembered redirect instead of correcting them.
  • Forgetting crawlers. Submit the production sitemap and let the old host 301 for a few weeks; removing it too early prolongs the cleanup.

Prevention

Temporary redirects get temporary semantics: 302 (or 307) with Cache-Control: no-store for anything that exists only during a migration window. Keep a launch-day list of every redirect created for the cutover and delete them the same day, then run the four-variant curl audit before announcing the site. The pattern of a launch is predictable — the leftovers are only a problem when nobody wrote down what was added.

If redirects keep fighting each other across Cloudflare, the origin, and the CMS, Stack Harbor untangles that chain as part of Managed Cloud Ops — book an infrastructure review.