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
This is something that only really makes sense for adapter-cloudflare and adapter-node, but: when a load function fetches a static asset (or a prerendered one, post #3849), it makes an actual fetch because options.read is only provided during dev/preview/prerendering:
In the Cloudflare/Node cases, that probably means we're leaving performance on the table, since the adapter is responsible for handling static assets (unlike platforms like Vercel and Netlify, which handle static assets before SvelteKit is invoked). Triggering a secondary HTTP request when we have the assets right there is wasteful.
Describe the proposed solution
app.render takes a second options argument. We could add an equivalent of options.read (which is currently set via override) there:
// node
-setResponse(res, await app.render(request));+setResponse(res, await app.render(request, {+ fetchAsset: ({ file, type }) => new Response(fs.readFileSync(path.join(__dirname, 'static', file)), {+ headers: { 'content-type': type }+ })+}));
Describe the problem
This is something that only really makes sense for
adapter-cloudflare
andadapter-node
, but: when aload
function fetches a static asset (or a prerendered one, post #3849), it makes an actualfetch
becauseoptions.read
is only provided during dev/preview/prerendering:kit/packages/kit/src/runtime/server/page/load_node.js
Lines 165 to 175 in d788cf2
In the Cloudflare/Node cases, that probably means we're leaving performance on the table, since the adapter is responsible for handling static assets (unlike platforms like Vercel and Netlify, which handle static assets before SvelteKit is invoked). Triggering a secondary HTTP request when we have the assets right there is wasteful.
Describe the proposed solution
app.render
takes a second options argument. We could add an equivalent ofoptions.read
(which is currently set viaoverride
) there:Alternatives considered
No response
Importance
nice to have
Additional Information
No response
The text was updated successfully, but these errors were encountered: