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
@@ -59,9 +59,9 @@ _headers
59
59
60
60
Now Wrangler will not upload these files as client-side assets when deploying the Worker.
61
61
62
-
## `experimental_serve_directly`
62
+
## `run_worker_first`
63
63
64
-
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).
64
+
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).
65
65
66
66
<WranglerConfig>
67
67
@@ -74,7 +74,7 @@ main = "src/index.ts"
74
74
[assets]
75
75
directory = "./public/"
76
76
binding = "ASSETS"
77
-
experimental_serve_directly = false
77
+
run_worker_first = true
78
78
```
79
79
80
80
</WranglerConfig>
@@ -166,16 +166,16 @@ For the various static asset routing configuration options, refer to [Routing](/
166
166
167
167
### Smart Placement with Worker Code First
168
168
169
-
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.
169
+
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.
170
170
171
-
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.
171
+
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.
172
172
173
173
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).
174
174
175
175
### Smart Placement with Assets First
176
176
177
-
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).
177
+
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).
178
178
179
-
Use Smart Placement with `experimental_serve_directly=true` when prioritizing fast asset delivery.
179
+
Use Smart Placement with `run_worker_first=false` (or not specifying it) when prioritizing fast asset delivery.
180
180
181
181
This will not impact the [default routing behavior](/workers/static-assets/routing/#default-behavior).
|[Serve assets on a path](/workers/static-assets/routing/)| ✅ | ❌ |
@@ -90,7 +90,7 @@ We plan to bridge the gaps between Workers and Pages and provide ways to migrate
90
90
91
91
[^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.
92
92
93
-
[^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.
93
+
[^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.
94
94
95
95
[^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
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ import {
15
15
Render,
16
16
TabItem,
17
17
Tabs,
18
-
WranglerConfig
18
+
WranglerConfig,
19
19
} from"~/components";
20
20
21
21
## Default behavior
@@ -38,7 +38,7 @@ In this example, a request to `example.com/api` doesn't match a static asset so
38
38
39
39
## Invoking Worker Script Ahead of Assets
40
40
41
-
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 the `wrangler.toml / wrangler.json`file 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.
41
+
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 / wrangler.json` 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.
42
42
43
43
Take the following directory structure, `wrangler.toml / wrangler.json` file, and user Worker code:
44
44
@@ -59,7 +59,7 @@ Take the following directory structure, `wrangler.toml / wrangler.json` file, an
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.
93
+
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.
94
94
95
95
## Routing configuration
96
96
@@ -321,3 +321,4 @@ In this example, requests to `example.com/blog/` will serve the `index.html` fil
321
321
322
322
If you have a file outside the configured path, it will not be served. For example, if you have a `home.html` file in the root of your asset directory, it will not be served when requesting `example.com/blog/home`.
323
323
However, if needed, these files can still be manually fetched over [the binding](/workers/static-assets/binding/#binding).
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
@@ -984,9 +984,9 @@ The following options are available under the `assets` key.
984
984
985
985
- The binding name used to refer to the assets. Optional, and only useful when a Worker script is set with `main`.
986
986
987
-
-`experimental_serve_directly` <Typetext="boolean" /> <MetaInfotext="optional, defaults to true" />
987
+
-`run_worker_first` <Typetext="boolean" /> <MetaInfotext="optional, defaults to false" />
988
988
989
-
- 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).
989
+
- 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