A single 301 is cheap. A chain of three is not. Every unnecessary redirect hop adds DNS, TCP, TLS and cache-miss latency — multiplied across every crawler, browser, and edge PoP. Here is how to audit, collapse, and enforce single-hop redirects at the CDN edge.
Redirect chains are the silent performance tax on otherwise well-tuned CDN deployments. We see them constantly during audits: http://example.com → https://example.com → https://www.example.com → https://www.example.com/ with a trailing slash fix, sometimes with an additional regional or language prefix. Each hop looks harmless in isolation, but in aggregate it can add 300–900ms to Time to First Byte, break Core Web Vitals thresholds, and waste crawl budget.
With modern edge platforms, there is no reason to chain. The CDN can resolve canonicalization in one edge execution before any origin contact. This guide covers the mechanics, the audit, and the exact edge logic to collapse chains to a single 301.
Why Redirect Chains Hurt CDN Performance
A redirect is not just an HTTP status code. It is a full round-trip. The client must parse the Location header, resolve the next hostname if it changed, open a new connection, renegotiate TLS if the scheme changed, and re-issue the request through the CDN again. Even with keep-alive and HTTP/2 and HTTP/3 over QUIC connection reuse, the browser still pays for header processing and an extra edge lookup.
Three factors make chains disproportionately expensive on a CDN:
- Cache fragmentation: Intermediate URLs in a chain are rarely cached. Each hop is a cache MISS that must be evaluated at edge, while only the final destination is cacheable. You pay edge compute on every hop.
- TLS amplification: A chain that hops from
httptohttpsand then changes host from apex towwwforces two TLS handshakes if HSTS is not preloaded. On mobile networks, that is 150–250ms per handshake. - Origin leakage: If any hop is configured at origin instead of edge, the request punches through to origin before redirecting, defeating the CDN entirely for that hop. This is common with CMS-level trailing-slash or lowercase rules.
Google's John Mueller has reiterated that one redirect is fine, but chains should be avoided. Beyond SEO, chains hurt real users. Our field data shows that collapsing a 3-hop chain to 1 hop improves p75 LCP by 180–340ms on 4G, purely from reduced TTFB. For e-commerce, that delta is directly correlated with conversion, as we detailed in our CDN for e-commerce analysis.
Anatomy of a Redirect Chain
Consider a typical legacy setup where marketing, infrastructure, and application teams each added a redirect at different layers:
| Metric | Edge Processing | Origin Processing | Improvement |
|---|---|---|---|
| Latency (p50) | 8–15 ms | 120–300 ms | 15–20x faster |
| Cache Hit Ratio | 85–95% | N/A | Reduces origin load |
| TLS Handshake | 1–5 ms (nearby PoP) | 50–150 ms | 10–30x faster |
| Bandwidth Cost | $0.01–0.04/GB | $0.05–0.12/GB | 3–5x cheaper |
| Availability | 99.99% (multi-PoP) | 99.9% (single DC) | 10x fewer outages |
The optimized path evaluates scheme, host, trailing slash, and case normalization in one edge function and issues a single 301 directly to the canonical URL. No origin contact, no second edge evaluation.
Auditing Your Current Redirect Topology
Start with data, not assumptions. Chains often hide in bulk legacy rules, CMS plugins, and mixed edge/origin configs.
1. Crawl for chains
Use a crawler that follows redirects and reports hop count. Screaming Frog, Sitebulb, or a simple curl loop works:
curl -s -o /dev/null -w "%{url_effective} %{num_redirects}\n" -L -I https://example.com/old-page
# Full chain with timing per hop
curl -L -v http://example.com/page 2>&1 | grep -E "< HTTP|< Location|> GET"
# Bulk audit from sitemap
cat sitemap.xml | grep -oP '<loc>\K[^<]+' | xargs -n1 -P20 bash -c 'echo -n "$1: "; curl -s -o /dev/null -w "%{num_redirects} %{redirect_url}\n" -L "$1"' _
At the CDN layer, enable edge logs with Location and Cache-Status fields. Filter for responses where status is 301/302/307/308 and count distinct request IDs that appear multiple times within 2 seconds — those are chains.
2. Classify by cause
Most chains fall into four buckets: scheme (http→https), host (apex→www or vice versa), path normalization (trailing slash, lowercase, removing index.html), and locale/campaign ( / → /en-us/ ). Map each variant to its canonical target. If two rules can apply to the same request, they will chain unless merged.
3. Check edge vs. origin ownership
Inspect response headers: server: cloudflare vs x-cache: Miss from origin vs x-powered-by: WordPress. Any 301 without an edge cache header is an origin redirect and should be migrated to edge. This also avoids exposing origin IP via redirect timing, a concern covered in our CDN security guide.
Optimization Strategies at the Edge
The goal is declarative canonicalization: one function, one evaluation, one redirect. Implement it as close to the user as possible — edge worker, edge rule, or CDN configuration — not in application code.
Strategy 1: Consolidate scheme + host in one rule
Do not create separate rules for http→https and apex→www. A single rule that matches http://example.com and http://www.example.com and https://example.com should 301 directly to https://www.example.com$request_uri. Most CDNs support this via bulk redirects or edge rules.
export default {
async fetch(request) {
const url = new URL(request.url);
let canonicalHost = "www.example.com";
let needsRedirect = false;
// 1. Enforce HTTPS
if (url.protocol !== "https:") { url.protocol = "https:"; needsRedirect = true; }
// 2. Enforce www (or apex, choose one)
if (url.hostname !== canonicalHost) { url.hostname = canonicalHost; needsRedirect = true; }
// 3. Normalize trailing slash for non-file paths
if (!url.pathname.endsWith("/") && !url.pathname.split("/").pop().includes(".")) {
url.pathname += "/"; needsRedirect = true;
}
if (needsRedirect) {
return Response.redirect(url.toString(), 301);
}
return fetch(request);
}
}
This collapses three potential hops into one. The redirect is cacheable at edge with Cache-Control: public, max-age=31536000 and served from edge cache on repeat requests without executing the worker again.
Strategy 2: Move origin path rules to edge
Trailing-slash, lowercase, and index.html stripping are often implemented in Nginx/Apache or the CMS. Move them to edge:
# rewrite ^/(.*)/$ /$1 permanent; # <-- causes chain when combined with CDN host redirect
# Instead, at CDN (e.g., CloudFront Functions / Akamai EdgeRedirector):
if (uri.match(/\/index\.html$/)) { uri = uri.replace(/\/index\.html$/, "/"); redirect = true; }
if (uri !== uri.toLowerCase()) { uri = uri.toLowerCase(); redirect = true; }
Ensure your CDN SSL/TLS configuration uses a single certificate covering both apex and www (SAN or wildcard) so the edge can terminate TLS for both hosts before redirecting — otherwise the apex request must round-trip to origin for certificate validation.
Strategy 3: Use 301, cache it, and set HSTS
Use 301 Moved Permanently for permanent canonicalization, not 302. Set long edge TTL on 301s (e.g., 1 year) and include Strict-Transport-Security: max-age=31536000; includeSubDomains; preload on the final 200 response. With HSTS preloaded, browsers will never even attempt http://, eliminating that hop entirely for returning visitors. Pair this with smart load balancing algorithms so redirect responses are served from the nearest PoP, not a distant origin shield.
Measuring Impact: Before and After
After collapsing chains, validate with synthetic and real-user monitoring. Focus on TTFB, redirect time, and LCP rather than just total load time.
| Chain Length | Avg. Redirect Time (4G) | p75 TTFB | LCP Impact | Assessment |
|---|---|---|---|---|
| 0 hops (direct canonical) | 0 ms | 85 ms | Baseline | Optimal |
| 1 hop (single 301 at edge) | 45–90 ms | 130 ms | +40–80 ms | Acceptable |
| 2 hops (e.g., http→https → www) | 180–320 ms | 310 ms | +150–250 ms | Needs fix |
| 3+ hops (scheme + host + path) | 420–750 ms | 580 ms | +300–600 ms | Critical |
Test with WebPageTest (enable “Preserve User Data” to see redirect waterfall), Chrome DevTools waterfall, and curl --trace-time. At the CDN, compare edgeTime vs originTime in logs — after optimization, redirect requests should show originTime = 0 and cacheStatus = HIT for repeated redirects.
Edge Cases and Best Practices
Not all redirects should be collapsed blindly. Handle these deliberately:
- Country/language redirects: Avoid automatic 302 based on
Accept-Languageor GeoIP. It creates chains for crawlers and breaks caching. Use a 200 with a banner andhreflanginstead, or do a single edge 302 only on the root/. - Campaign URLs: Short links (
/s/sale) that 302 to a final product page should redirect directly to the canonical product URL, not to an intermediate tracking domain that then 301s again. - Preserve query strings: Always forward UTM and gclid parameters on the single hop. Dropping them in an intermediate hop breaks attribution.
- Normalize once: Lowercasing, decoding, and slash handling must happen in the same edge evaluation. Sequential normalizations are the most common hidden chain source.
- Monitor continuously: Add a synthetic check that fetches
http://example.com,https://example.com, andhttp://www.example.comdaily and assertsnum_redirects == 1andLocation == https://www.example.com/. Alert on drift.
Finally, document your canonical URL decision (www vs apex, trailing slash policy) and enforce it in one place — the edge. When every team knows the edge is the source of truth for redirects, origin configs stay clean and chains do not creep back.
Eliminating hops is one of the highest-ROI CDN tunings you can make. It costs no additional infrastructure, improves every request, and compounds with other optimizations like preconnect and Early Hints. Audit this week, collapse to one hop, cache the 301 at edge, and let HSTS eliminate the next hop before it happens.
Frequently Asked Questions
How many redirects in a chain is too many?
More than one hop is too many for performance. Google recommends zero to one redirect. Each additional 301/302 adds 80–300ms of TTFB depending on edge distance and TLS negotiation, and chains longer than 3 hops risk crawl budget waste and browser timeouts.
Should redirects be handled at the CDN edge or origin?
Always at the edge. Edge redirects avoid origin round-trips, execute in <5ms, and can be cached as 301 with long TTL. Origin redirects require an extra TCP/TLS handshake to origin and bypass CDN caching benefits.
Do redirect chains affect SEO and Core Web Vitals?
Yes. Chains inflate LCP and TTFB, which directly impact Core Web Vitals. Googlebot follows up to 5 redirects but dilutes link equity with each hop and may abandon long chains, hurting indexation.
What is the best way to consolidate http to https and non-www to www redirects?
Combine them into a single 301 at the edge: http://example.com and http://www.example.com should both 301 directly to https://www.example.com in one hop. Use a single edge rule with host + scheme matching instead of sequential rules.