One CloudFront investigation turned on a page from the wrong environment. Two public aliases requested the same path, but environment-specific content and canonical metadata were not reliably isolated at the cache boundary.
That was a cached HTML failure, not a recorded redirect loop. It is still a useful starting point for redirect debugging: when two requests are treated as interchangeable, the edge may reuse the wrong response even after the origin is correct.
The cross-alias HTML failure is an anonymized deployment experience supported by deployment notes. The redirect loop below is a separate hypothetical example; no captured loop is claimed for that incident.
What the cross-alias failure established
In the retained deployment record, alternating requests for the same path on two hostnames exposed a cache-boundary failure. The expected environment-specific markers and canonical metadata were not consistently isolated. The application could produce the right response, yet the edge could reuse a response that belonged to another hostname.
The documented repair moved host-sensitive HTML to zero-TTL caching and invalidated the affected cached responses. Alternating same-path checks then distinguished the intended environments. The useful evidence was the content and metadata seen at each public hostname, rather than the distribution simply reporting a successful deployment.
That experience changes how to read a cached redirect. If a response varies by a value that the cache key does not distinguish, the edge can reuse the wrong routing decision just as it can reuse the wrong HTML. A successful origin request alone cannot prove that the public cache contract is correct.
Reconstruct the first wrong transition
Consider a WordPress site behind CloudFront. Viewers use HTTPS, but the configured origin hop uses HTTP. The origin redirects every HTTP request to the public HTTPS URL. CloudFront fetches that URL’s origin response over HTTP again, and the same decision repeats.
Simplified, hypothetical loop
Viewer: HTTPS /article/
-> CloudFront: HTTP origin request
-> Origin: redirect to HTTPS /article/
-> Viewer repeats the same public request
The browser is not failing to understand HTTPS. Two layers disagree about which connection’s scheme should control the redirect. Increasing a redirect limit only repeats the disagreement more times.
A different loop can occur when an edge rule chooses www.example.com while application canonical settings choose example.com. Both individual rules can look reasonable in isolation. The chain shows that they cannot both own the final hostname.
Capture the first wrong response
Start with a GET whose body is discarded. A HEAD request is useful too, but some applications handle it differently, so do not let a successful HEAD stand in for the failing request.
curl -sS -o /dev/null -D - 'https://www.example.com/article/?probe=one'
curl -sS -L --max-redirs 8 -o /dev/null \
-w 'final=%{url_effective} code=%{http_code} hops=%{num_redirects}\n' \
'https://www.example.com/article/?probe=one'
These documentation-domain commands illustrate the inspection; substitute only an approved target. Record each status and Location, along with cache evidence such as Age and X-Cache when present. The repair point is the first transition that violates the intended route, not the last URL printed by the client.
An edge cache hit is useful evidence, but a miss does not automatically prove the application generated the response. A viewer-request function can act before cache lookup. Read function associations and origin behavior alongside response headers.
Check whether the probe changes the cache key
A random ?probe= value only bypasses a cached object if the relevant cache policy actually distinguishes that query. If it does not, repeated probes can select the same cached response. If the application uses query parameters for search or other dynamic behavior, ignoring them may be a correctness problem rather than merely a debugging inconvenience.
Inspect the behavior matching the failing path. Do not assume the default behavior’s policy governs every application route.
Give each routing decision an owner
Write down which layer owns HTTPS normalization, canonical hostname and old-path migration. Also record what the origin must know about the viewer request. An application should trust forwarded host or scheme information only through the controlled proxy boundary; an arbitrary incoming header must not become a redirect authority.
Using HTTPS to the origin can simplify the scheme contract, but it brings origin certificate and hostname requirements. Keeping HTTP on a deliberately private, reviewed origin hop requires a correct trusted-viewer-scheme model. Neither option is fixed by copying a forwarded-proto snippet without understanding who can reach that origin.
For WordPress, review home, siteurl, proxy HTTPS detection and application-level redirects together. A new edge function does not cancel an old canonical rule. A rollback must restore a coherent set of assumptions across both layers.
Correct the origin, then retire the bad cache object
Invalidating before correcting the decision can simply repopulate the same bad redirect. Conversely, correcting the origin without dealing with an existing cached response can leave users seeing a failure that no longer appears in an origin test.
CloudFront policy TTLs matter here. A nonzero minimum TTL can override origin cache directives that an operator expects to prevent reuse. For host-sensitive dynamic HTML, the retained experience used caching disabled rather than trying to preserve an unsafe shared object. Static assets can have a different, versioned caching policy.
Temporary redirects need explicit, reviewed caching behavior during a migration. A temporary status is not a universal instruction to every cache to forget it. Permanent redirects add a second problem: invalidating the edge cannot erase a browser’s remembered decision.
Verify the public route after the cache change
Test HTTP and HTTPS, apex and www, a real content path, a search query and any method-sensitive endpoint. Assert the intended destination and query handling, not just a final 200. Compare canonical metadata and internal links with that destination.
Where origin access is explicitly authorized, compare the origin and public path while preserving the intended Host and TLS server name. Do not expose an origin or disable certificate verification just to make a test easy.
Keep the alternating-host test in the regression set. A future cache-policy change should have to preserve the environment-specific content and canonical destination on each hostname. That test targets the demonstrated failure; the scheme and method tests cover the separate redirect risks.
Sources and further investigation
References support the protocol and product behavior discussed here; they are not evidence that the illustrative scenario occurred.
- CloudFront managed cache policies
- CloudFront custom-origin request and response behavior
- CloudFront cache behavior settings
- CloudFront invalidation documentation