Skip to content

CloudFront still returns 404 after the page is published

Separate a cached CloudFront error from a missing origin page, inspect error-cache settings, and verify the published URL after a scoped repair.

By Crawlito · 5 min read

In short

  • CloudFront can retain an error response after the origin resource becomes available.
  • Error caching has controls separate from the normal successful-object cache.
  • Verify the origin state and the public edge response before deciding what to invalidate.
On this page

If CloudFront keeps returning 404 after a page or asset is published, confirm that the origin now serves the resource and inspect the cached error's lifetime. A cached failure can outlive the deployment that fixed the origin. Repair any remaining origin problem first, then let the applicable error cache expire or invalidate the affected public path through the normal process.

Do not treat every post-deployment 404 as stale caching. A wrong origin path, missing build artifact, or incorrect cache behavior can produce a fresh failure on every request.

Capture the public error and the release state

Save the failing response with a real GET:

bash
curl -sS -D edge-headers.txt -o edge-body.txt \
  'https://www.example.com/guides/new-release'

Record the status, headers, response body, and time. Check whether the body is the expected custom error page or something generated by another service.

Then confirm the deployment actually contains the requested resource. A successful build does not prove that the file was uploaded to the origin path used by this cache behavior.

AWS documents CloudFront error caching separately from ordinary object freshness. At the time of writing, its default error-caching duration is ten seconds, but configured values and origin headers can change the effective behavior.

Use your distribution's actual settings rather than assuming the default explains a long incident.

Verify the origin through an authorized path

Use the origin's supported deployment or access tools to confirm the resource exists and returns the intended content. Do not make a private bucket public to simplify this test.

Match the requested path precisely. A distribution can prepend an origin path, choose a different origin by behavior, or rewrite the request. The file visible in storage may not be the file CloudFront requests.

Check case, trailing slashes, and the build's actual route output. An HTML page at one path does not satisfy a request for another merely because the names look similar.

If the origin still fails, repair that cause first. Invalidating the edge repeatedly will only fetch and cache another error.

The CloudFront deep-link guide covers a related routing problem. Here the focus is the case where a previously missing resource is now genuinely available at the intended origin path.

Inspect the error-caching configuration

Identify the behavior that matches the URL and the status CloudFront receives from the origin. Review its custom error response settings and any applicable origin cache headers.

AWS explains that the effective error lifetime can depend on the configured minimum and origin headers, subject to the relevant limits. Do not assume changing the normal successful-object TTL changes every error response.

Also check whether CloudFront transforms the origin status into a different viewer status. A custom error page returned as 200 can hide the failure from a superficial availability check.

Use a compact record:

ItemEvidence
Requested pathExact public URL path
Matched behaviorOrigin and applicable policy
Origin stateCorrect resource or current failure
Error policyRelevant status and lifetime
Viewer responseActual status and body

This makes the repair specific enough for an infrastructure owner to review.

Choose a scoped recovery

Once the origin is correct, decide whether waiting for the documented remaining lifetime is sufficient or whether a scoped invalidation is appropriate for the release.

AWS documents invalidating the requested object path to remove a cached error. Use the path actually requested by the viewer and follow your distribution's normal invalidation workflow.

Do not invalidate the entire site by habit. A narrow path or deliberate affected set is easier to verify and avoids unnecessary cache churn.

If a wildcard is needed because a known deployment pattern affected several resources, document the reason and scope. Keep the operation tied to the confirmed incident.

Avoid setting every error lifetime to zero permanently as an immediate reaction. Error caching can reduce repeated origin load during real failures. Review the intended tradeoff using the site's actual workload rather than treating caching itself as the defect.

Verify the edge after the recovery

Repeat the original public GET without random query parameters. A cache-busting query may select a different cache entry and conceal the state readers encounter at the normal URL.

Confirm the intended title and body or, for an asset, its actual file content. A successful status with the custom error page still present is not a completed repair.

Test the same URL after the recovery process reports completion. Save the time and response so another person can distinguish a queued invalidation from a verified live change.

The CDN freshness guide explains why the canonical request path matters. Preserve that same path throughout the before and after comparison.

If the error returns, inspect whether an origin deployment removed the object again or whether another behavior routes part of the traffic elsewhere. Repeated invalidation is not a substitute for a stable origin.

Test missing resources as a control

After fixing the published page, request a deliberately nonexistent public path within the same intended route family. It should have an honest missing-resource response.

This catches a workaround that converts all errors into successful copies of the homepage. Such a change may make monitoring green while giving readers and crawlers unrelated content.

The soft 404 guide covers this distinction. Your positive case and negative control should both behave correctly.

Also check an older published page using the same behavior. The repair should not break existing content or alter its cache contract unintentionally.

For the release record, keep three examples: the newly published resource, an existing resource, and a missing resource. Together they provide more useful evidence than repeatedly fetching one successful URL.

Prevent publication-order races

Review whether links or sitemap entries become public before the resources they reference. A reader or crawler can request the new URL during that gap and cause an error response to be cached.

Where the platform supports it, publish resources before advertising their URLs, or use an atomic release model that keeps the public set coherent.

For static assets with versioned names, confirm the deployment uploads the new objects before the HTML references them. For generated pages, confirm the route artifact is part of the same released set.

Do not make publication dates inaccurate to hide a delivery race. Fix the order or release mechanism and retain the actual content timeline.

Add a post-release fetch of each important new public route before announcing completion. That small check detects both missing artifacts and cached errors at the point where readers encounter them.

If a custom error document is involved, verify that document's own location and delivery behavior. A missing error-page asset can complicate the visible result without explaining why the original article was unavailable. Keep the article request and the error-document request separate in the incident notes. After the article succeeds, request a deliberately missing path again to confirm that genuine failures still receive the intended error response and usable explanation.

Frequently asked questions

Does a cached 404 prove the origin is currently broken?

No. Verify the origin's current state and the public edge response separately.

Should I append a random query to prove the fix?

That may test a different cache entry. Verify the ordinary public URL that appears in links and the sitemap.

Does a completed invalidation prove the article is correct?

No. Fetch the URL and inspect the intended content after the invalidation completes.

Run the recovered article URL through the free Crawlito check before marking the publication complete.

Filed under Platform guides. Topics: caching, http-status, troubleshooting