From 9daf8d6af4dc92d052bb12f0b7aa14d4593f4262 Mon Sep 17 00:00:00 2001 From: Greg Brimble Date: Thu, 3 Apr 2025 12:42:21 -0400 Subject: [PATCH] Add compat flag for assets --- .../assets-navigation-prefers-asset-serving.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/content/compatibility-flags/assets-navigation-prefers-asset-serving.md diff --git a/src/content/compatibility-flags/assets-navigation-prefers-asset-serving.md b/src/content/compatibility-flags/assets-navigation-prefers-asset-serving.md new file mode 100644 index 00000000000000..ba62c5cd6d5ef4 --- /dev/null +++ b/src/content/compatibility-flags/assets-navigation-prefers-asset-serving.md @@ -0,0 +1,18 @@ +--- +_build: + publishResources: false + render: never + list: never + +name: "Navigation requests prefer asset serving" +sort_date: "2025-04-01" +enable_date: "2025-04-01" +enable_flag: "assets_navigation_prefers_asset_serving" +disable_flag: "assets_navigation_has_no_effect" +--- + +For Workers with [static assets](/workers/static-assets/) and this compatibility flag enabled, navigation requests (requests which have a `Sec-Fetch-Mode: navigate` header) will prefer to be served by our asset-serving logic, even when an exact asset match cannot be found. This is particularly useful for applications which operate in either [Single Page Application (SPA) mode](/workers/static-assets/routing/#not_found_handling--404-page--single-page-application--none) or [404 page mode](/workers/static-assets/routing/#not_found_handling--404-page--single-page-application--none), as this now means the fallback pages of `200 /index.html` and `404 /404.html` will be served ahead of invoking a Worker script and will therefore avoid incurring a charge. + +Without this flag, the runtime will continue to apply the old behavior of invoking a Worker script (if present) for any requests which don't exactly match a static asset. + +This compatibility flag has no effect when `assets.run_worker_first = true` is set. `assets.run_worker_first = true` will continue to force the Worker script to execute ahead of all other asset-serving logic.