Skip to content

Upcoming change to Cloudflare Pages projects #6441

@jrf0110

Description

@jrf0110

Describe the problem

👋

Hi there. John here from the Cloudflare Pages team.

When a SvelteKit project is deployed to Cloudflare Pages, the server-side code is supported through Pages Functions (currently in beta). Unfortunately, by using Functions, each request must go through the server-side Functions code even if it doesn't need to. For instance, an immutable asset request to https://kit.svelte.dev/_app/immutable/assets/_layout-ab34ca4f.css would first have to route through Functions.

This is problematic since the request would "count" as a request to Functions even though only a static asset was served. Further, there is a slight amount of added latency.

Describe the proposed solution

The Cloudflare Pages team has been rolling out support to customize how project Functions are mounted and thus can save money and latency by providing this metadata on build. The @sveltejs/adapter-cloudflare package should expose a set of includes and excludes based on static files generated. For the time being, I suggest we be conservative and include the Functions worker on all routes but exclude on /_app/immutable/.

If the SvelteKit user uses the hooks functionality, they may need to tune these patterns manually on a case-by-case basis.

Alternatives considered

No response

Importance

nice to have

Additional Information

We (the Cloudflare Pages team) will be contributing the relevant changes.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions