Static assets (public folder)
The static assets of Next located in the public folder (opens in a new tab) are served using Workers Static Assets (opens in a new tab).
Workers Static Assets can intercept requests to the application (run_worker_first=false
(opens in a new tab) which is the default). This is the most cost efficient option as asset requests will not be billed in that case.
Another option is to run the Worker first (run_worker_first=true
) to offer more flexibility at the expense of a higher cost.
Note that run_worker_first
could also be set to a list of patterns - this is a great option if you need more flexibility for only a subset of the statids assets.
run_worker_first=false
When run_worker_first
is set to false
, requests are intercepted before reaching the worker and are not billed:
// wrangler.jsonc
{
"name": "my-app",
// ...
"assets": {
"directory": ".open-next/assets",
"binding": "ASSETS",
// Optional as false is the default value
"run_worker_first": false,
},
// ...
}
This is the most cost efficient option to use when you do not need to serve assets behind the middleware or Next rewrites and headers from the Next config (opens in a new tab).
When run_worker_first=false
you can still configure headers (opens in a new tab) and redirects (opens in a new tab) via Worker Static Assets.
run_worker_first=true
When run_worker_first
is set to true
, all the requests will reach the Worker and be billed:
// wrangler.jsonc
{
"name": "my-app",
// ...
"assets": {
"directory": ".open-next/assets",
"binding": "ASSETS",
"run_worker_first": true,
},
// ...
}
The Open Next asset resolver will be used to retrieve the assets from the Worker.
When run_worker_first=true
, assets are served behind the middleware and Next rewrites and headers from the Next config (opens in a new tab). The headers (opens in a new tab) and redirects (opens in a new tab) configured for the Worker Static Assets do not apply in this case.
run_worker_first=true
should be used if you plan to use skew protection.