Static assets
Every site’s files are served by Workers static assets, from Cloudflare’s edge. A site can be static files alone, or a Worker with assets beside it.
Static files alone
Section titled “Static files alone”A build without a Worker of its own (an Astro or Eleventy site, a Vite app, or a folder of HTML) is deployed with a small script from Digize that serves the files and passes form posts to the platform: a POST to any path ending in /_platform/forms goes on to Forms with the visitor’s address, so a static site’s forms work without code.
Which folder is deployed comes from the framework or the Output directory setting (Build settings). What a path that has no file gets depends on the framework:
| Framework | A path with no file |
|---|---|
| Astro, SvelteKit, Nuxt, Eleventy, a folder of files | The nearest 404.html, with status 404 |
| Vite | index.html, for a single-page app’s own routing |
Pages are served with auto-trailing-slash HTML handling: /about serves about.html or about/index.html, and redirects to the form that matches the file.
A Worker with assets
Section titled “A Worker with assets”With a wrangler.jsonc that has assets.directory, those files are uploaded and the Worker gets them on its assets binding (ASSETS, or the binding you name). These keys of assets are kept:
| Key | Default here |
|---|---|
binding |
ASSETS |
not_found_handling |
none: a path with no file runs the Worker |
html_handling |
auto-trailing-slash |
run_worker_first |
false: a path with a file is served without running the Worker |
interface Env { ASSETS: Fetcher;}
export default { async fetch(request: Request, env: Env): Promise<Response> { const url = new URL(request.url); if (url.pathname.startsWith("/api/")) { return Response.json({ ok: true }); } return env.ASSETS.fetch(request); },};_headers, _redirects and .assetsignore
Section titled “_headers, _redirects and .assetsignore”_headersand_redirectsat the top of the assets folder are applied as Workers static assets applies them..assetsignorein the assets folder leaves out files, with.gitignoresyntax (globs,!to put back,/to anchor, a trailing/for folders)..git,node_modulesand a_worker.jsfile or folder are never uploaded as files.
Content types
Section titled “Content types”Files are served with a type from their extension: HTML, CSS, JavaScript, JSON, source maps, web manifests, XML, plain text, Markdown, SVG, PNG, JPEG, GIF, WebP, AVIF, icons, WOFF, WOFF2, TTF and OTF fonts, MP4 and WebM video, MP3 audio, PDF and WebAssembly. Anything else, such as a .csv file, is application/octet-stream.
The size limits for files, a version’s assets and the whole build are on Limits.