You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Website] Cache public Playground 404 responses at the edge - #4655
Mark ordinary router-generated GET and HEAD 404s for edge caching on the app and WordPress sandbox hosts. The origin sends A8C-Edge-Cache: cache and requests a 60-second shared-cache lifetime with immediate browser revalidation.
Keep no-store on PHP endpoint errors, scoped navigation fallbacks, and other errors.
WordPress at a scoped URL runs in the browser. Safari can open a scoped link in a new tab outside the sandbox service worker's control. If that top-level GET reaches WP Cloud, the sandbox redirects it to the app. The app serves a wrapper that recreates the WordPress iframe and reconnects it to the running site. A scoped iframe request that reaches the server receives a 404. Keep that 404 uncached so the edge can still route a later top-level GET to the wrapper. This preserves the existing Safari new-tab fallback.
WP Cloud and deployment
The installer publishes the complete release directory and activates the root files before requesting a full-domain purge for each hostname. The WP Cloud API schema documents that the domain-specific purge clears the whole domain when purge_uris is omitted. The existing deployment check already accounts for propagation delay by waiting for the new root loaders on both hosts.
A cached 404 can still be served while that purge propagates. An origin request started before publication could also finish after a purge and refill the cache if WP Cloud allows in-flight responses to be stored then. The public API does not specify that behavior. The Edge Cache docs document the opt-out header and the x-ac hit signal, but leave PHP-generated 404 eligibility and the effect of s-maxage unspecified. WP Cloud documents that it can supply its own cache headers for cached responses. The requested 60 seconds should therefore be treated as an origin directive until verified on WP Cloud. HTTP and security headers
Before activation
After publishing the versioned files, the installer performs GET requests for the versioned worker on both hosts, the remote page on the app host, and the WordPress bridge on the sandbox host. If any return 404, it requests a hostname-specific purge of only those release URLs and waits for HTTP 200. A failed probe or purge leaves the previous release active. The existing full-domain purges still run after activation.
The router fixture verifies that a targeted purge runs while the root worker still points to the previous release and that an unsuccessful probe leaves the root worker in place. A live staging run remains necessary to verify the targeted purge against WP Cloud and observe propagation.
Verification
Passed the PHP deployment tests, PHP syntax check, and the Nx router and static-file range targets.
On WP Cloud staging, request the same missing URL without cookies on each host until it yields a 404 with x-ac: … HIT. Then publish a file at that URL through the normal deployment and check that each host serves 200 after the purge. This would verify both eligibility and invalidation on WP Cloud.
Summary by CodeRabbit
Bug Fixes
Corrected caching for missing-page responses. Eligible GET and HEAD requests can be cached briefly, while POST requests and other error responses are not cached.
Preserved no-cache behavior for iframe fallback errors and scoped sandbox requests.
Deployment
Required release assets are checked on both hosts before activation. Missing assets trigger targeted purges and rechecks; other failed checks or assets that remain unavailable prevent activation, leaving the previous release active.
After successful checks and activation, both domains are purged.
No actionable comments were generated in the recent review.
Walkthrough
The change updates cache headers for eligible missing-path responses. The deployment installer checks versioned release URLs before activation, requests targeted purges after 404 responses, and keeps the previous release active if checks fail.
Changes: 404 response caching
Layer / File(s)
Summary
Set headers for eligible 404 responses packages/playground/website-deployment/custom-redirects-lib.php, packages/playground/website-deployment/wordpress-frame/test-router.mjs
Marked GET and HEAD 404 responses receive shared-cache headers. Other error responses remain uncached. Tests cover both hosts, GET/HEAD/POST methods, and scoped iframe responses.
Release verification
Layer / File(s)
Summary
Check release assets before activation packages/playground/website-deployment/apply-update.sh, packages/playground/website-deployment/wordpress-frame/test-router.mjs, packages/playground/website-deployment/README.md, AGENTS.md
The installer checks release files and versioned URLs on both hosts. It requests targeted purges and retries when a URL returns 404. Other non-200 statuses or a 60-second timeout prevent activation. Tests cover blocked and stale assets and targeted purge details. The deployment guidance describes the checks and activation sequence.
The change lets the edge cache ordinary Playground 404 responses for 60 seconds. Scoped iframe 404s and endpoint errors stay uncached, and a deployment that fails its pre-activation checks leaves the previous release in place. I found no merge-blocking risk; confirm the edge-cache behavior on WP Cloud staging after deployment.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "[Website] Cache public Playground 404 responses at the edge" matches the main change. The objectives say the PR marks ordinary router-generated GET and HEAD 404s on the app and WordPress sa…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "[Website] Cache public Playground 404 responses at the edge" matches the main change. The objectives say the PR marks ordinary router-generated GET and HEAD 404s on the app and WordPress sandbox hosts for edge caching. The changeset's summaries show the same: 404 cache headers are deferred and cacheable 404s get edge-cache and s-maxage headers. The title does not mention the deployment changes (root-file switch checks, targeted purges), but those support the main change and are not the headline.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Mark ordinary router-generated GET and HEAD 404s for edge caching on the app and WordPress sandbox hosts. The origin sends
A8C-Edge-Cache: cacheand requests a 60-second shared-cache lifetime with immediate browser revalidation.Keep
no-storeon PHP endpoint errors, scoped navigation fallbacks, and other errors.WordPress at a scoped URL runs in the browser. Safari can open a scoped link in a new tab outside the sandbox service worker's control. If that top-level GET reaches WP Cloud, the sandbox redirects it to the app. The app serves a wrapper that recreates the WordPress iframe and reconnects it to the running site. A scoped iframe request that reaches the server receives a 404. Keep that 404 uncached so the edge can still route a later top-level GET to the wrapper. This preserves the existing Safari new-tab fallback.
WP Cloud and deployment
The installer publishes the complete release directory and activates the root files before requesting a full-domain purge for each hostname. The WP Cloud API schema documents that the domain-specific purge clears the whole domain when
purge_urisis omitted. The existing deployment check already accounts for propagation delay by waiting for the new root loaders on both hosts.A cached 404 can still be served while that purge propagates. An origin request started before publication could also finish after a purge and refill the cache if WP Cloud allows in-flight responses to be stored then. The public API does not specify that behavior. The Edge Cache docs document the opt-out header and the
x-achit signal, but leave PHP-generated 404 eligibility and the effect ofs-maxageunspecified. WP Cloud documents that it can supply its own cache headers for cached responses. The requested 60 seconds should therefore be treated as an origin directive until verified on WP Cloud. HTTP and security headersBefore activation
After publishing the versioned files, the installer performs GET requests for the versioned worker on both hosts, the remote page on the app host, and the WordPress bridge on the sandbox host. If any return 404, it requests a hostname-specific purge of only those release URLs and waits for HTTP 200. A failed probe or purge leaves the previous release active. The existing full-domain purges still run after activation.
The router fixture verifies that a targeted purge runs while the root worker still points to the previous release and that an unsuccessful probe leaves the root worker in place. A live staging run remains necessary to verify the targeted purge against WP Cloud and observe propagation.
Verification
x-ac: … HIT. Then publish a file at that URL through the normal deployment and check that each host serves 200 after the purge. This would verify both eligibility and invalidation on WP Cloud.Summary by CodeRabbit