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
Copy file name to clipboardExpand all lines: src/content/docs/workers/static-assets/binding.mdx
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,9 +60,9 @@ _headers
60
60
61
61
Now Wrangler will not upload these files as client-side assets when deploying the Worker.
62
62
63
-
## `experimental_serve_directly`
63
+
## `run_worker_first`
64
64
65
-
Controls whether assets will be served first on a matching request. `experimental_serve_directly = true` ([default](/workers/static-assets/routing/#default-behavior)) will serve any static asset matching a request, while `experimental_serve_directly = false` will unconditionally [invoke your Worker script](/workers/static-assets/routing/#invoking-worker-script-ahead-of-assets).
65
+
Controls whether to invoke the Worker script regardless of a request which would have otherwise matched an asset. `run_worker_first = false` ([default](/workers/static-assets/routing/#default-behavior)) will serve any static asset matching a request, while `run_worker_first = true` will unconditionally [invoke your Worker script](/workers/static-assets/routing/#invoking-worker-script-ahead-of-assets).
66
66
67
67
<WranglerConfig>
68
68
@@ -75,7 +75,7 @@ main = "src/index.ts"
75
75
[assets]
76
76
directory = "./public/"
77
77
binding = "ASSETS"
78
-
experimental_serve_directly = false
78
+
run_worker_first = true
79
79
```
80
80
81
81
</WranglerConfig>
@@ -167,16 +167,16 @@ For the various static asset routing configuration options, refer to [Routing](/
167
167
168
168
### Smart Placement with Worker Code First
169
169
170
-
If you desire to run your [Worker code ahead of assets](/workers/static-assets/routing/#invoking-worker-script-ahead-of-assets) by setting `experimental_serve_directly=false`, all requests must first travel to your Smart-Placed Worker. As a result, you may experience increased latency for asset requests.
170
+
If you desire to run your [Worker code ahead of assets](/workers/static-assets/routing/#invoking-worker-script-ahead-of-assets) by setting `run_worker_first=true`, all requests must first travel to your Smart-Placed Worker. As a result, you may experience increased latency for asset requests.
171
171
172
-
Use Smart Placement with `experimental_serve_directly=false` when you need to integrate with other backend services, authenticate requests before serving any assets, or if your want to make modifications to your assets before serving them.
172
+
Use Smart Placement with `run_worker_first=true` when you need to integrate with other backend services, authenticate requests before serving any assets, or if your want to make modifications to your assets before serving them.
173
173
174
174
If you want some assets served as quickly as possible to the user, but others to be served behind a smart-placed Worker, considering splitting your app into multiple Workers and [using service bindings to connect them](/workers/configuration/smart-placement/#best-practices).
175
175
176
176
### Smart Placement with Assets First
177
177
178
-
Enabling Smart Placement with `experimental_serve_directly=true` lets you serve assets from as close as possible to your users, but moves your Worker logic to run most efficiently (such as near a database).
178
+
Enabling Smart Placement with `run_worker_first=false` (or not specifying it) lets you serve assets from as close as possible to your users, but moves your Worker logic to run most efficiently (such as near a database).
179
179
180
-
Use Smart Placement with `experimental_serve_directly=true` when prioritizing fast asset delivery.
180
+
Use Smart Placement with `run_worker_first=false` (or not specifying it) when prioritizing fast asset delivery.
181
181
182
182
This will not impact the [default routing behavior](/workers/static-assets/routing/#default-behavior).
|[Serve assets on a path](/workers/static-assets/routing/)| ✅ | ❌ |
@@ -85,7 +85,7 @@ We plan to bridge the gaps between Workers and Pages and provide ways to migrate
85
85
86
86
[^1]: Similar to <sup>3</sup>, to customize the HTTP headers that are returned by static assets, you can use [Service bindings](/workers/runtime-apis/bindings/service-bindings/) to connect a Worker in front of the Worker with assets.
87
87
88
-
[^2]: Middleware can be configured via the [`experimental_serve_directly`](/workers/static-assets/binding/#experimental_serve_directly) option, but is charged as a normal Worker invocation. We plan to explore additional related options in the future.
88
+
[^2]: Middleware can be configured via the [`run_worker_first`](/workers/static-assets/binding/#run_worker_first) option, but is charged as a normal Worker invocation. We plan to explore additional related options in the future.
89
89
90
90
[^3]: You can handle redirects by adding code to your Worker (a [community package](https://npmjs.com/package/redirects-in-workers) is available for `_redirects` support), or you can use [Bulk Redirects](/rules/url-forwarding/bulk-redirects/).
Copy file name to clipboardExpand all lines: src/content/docs/workers/static-assets/routing.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ In this example, a request to `example.com/api` doesn't match a static asset so
39
39
40
40
## Invoking Worker Script Ahead of Assets
41
41
42
-
You may wish to run code before assets are served. This is often the case when implementing authentication, logging, personalization, internationalization, or other similar functions. [`experimental_serve_directly`](/workers/static-assets/binding/#experimental_serve_directly) is a configuration option available in `wrangler.toml` which controls this behavior. When disabled, `experimental_serve_directly = false` will invoke your Worker's code, regardless of any assets that would have otherwise matched.
42
+
You may wish to run code before assets are served. This is often the case when implementing authentication, logging, personalization, internationalization, or other similar functions. [`run_worker_first`](/workers/static-assets/binding/#run_worker_first) is a configuration option available in `wrangler.toml` which controls this behavior. When enabled, `run_worker_first = true` will invoke your Worker's code, regardless of any assets that would have otherwise matched.
43
43
44
44
Take the following directory structure, wrangler.toml, and user Worker code:
45
45
@@ -60,7 +60,7 @@ Take the following directory structure, wrangler.toml, and user Worker code:
In this example, any request will be routed to our user Worker, due to `experimental_serve_directly` being disabled. As a result, any request being made `/supersecret.txt` without an `Authorization` header will result in a 403.
94
+
In this example, any request will be routed to our user Worker, due to `run_worker_first` being enabled. As a result, any request being made `/supersecret.txt` without an `Authorization` header will result in a 403.
Copy file name to clipboardExpand all lines: src/content/docs/workers/wrangler/configuration.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -986,9 +986,9 @@ The following options are available under the `assets` key.
986
986
987
987
- The binding name used to refer to the assets. Optional, and only useful when a Worker script is set with `main`.
988
988
989
-
-`experimental_serve_directly` <Typetext="boolean" /> <MetaInfotext="optional, defaults to true" />
989
+
-`run_worker_first` <Typetext="boolean" /> <MetaInfotext="optional, defaults to false" />
990
990
991
-
- Controls whether static assets are fetched directly, or a Worker script is invoked. Learn more about fetching assets when using [`experimental_serve_directly`](/workers/static-assets/routing/#invoking-worker-script-ahead-of-assets).
991
+
- Controls whether static assets are fetched directly, or a Worker script is invoked. Learn more about fetching assets when using [`run_worker_first`](/workers/static-assets/routing/#invoking-worker-script-ahead-of-assets).
0 commit comments