Cloudflare Pages File Limit for Astro: Pages vs Workers
If a large Astro build fails while uploading to Cloudflare Pages, count the files in dist/ before changing the framework or deleting generated pages. Cloudflare’s current Pages limits allow 20,000 files on the Free plan and up to 100,000 on paid plans when the Pages Wrangler v4 setting is enabled. Workers Static Assets has the same 20,000 Free and 100,000 paid file counts, so moving products is not a way to get an unlimited static file budget.
The right decision depends on two separate questions: how many files the build produces, and whether the Astro site is truly static or needs request-time rendering and bindings.
Count the build output before choosing a platform
Run the same build that your deployment uses, then inspect the generated directory:
pnpm buildfind dist -type f | wc -ldu -sh distfind dist -type f -size +25M -printThe file count is the first limit to compare. The individual Cloudflare Pages asset limit is currently 25 MiB, so a site can fail even when its file count is small if one generated asset is too large. Treat the output from find as a deployment input; do not count only Markdown or source files.
Choose Pages, paid Pages, or Workers
| Build situation | Practical next check | Why |
|---|---|---|
| Static Astro site below 20,000 files | Keep Pages Free or use another static host | The build is below the current Free file limit. |
| Static site above 20,000 but below 100,000 files | Use paid Pages and set PAGES_WRANGLER_MAJOR_VERSION=4, or compare paid Workers Static Assets | The higher file limit is tied to the plan and Wrangler setting. |
| Static site above 100,000 files | Reduce generated output, split the site, or change the rendering model | Neither the documented paid Pages nor paid Workers Static Assets limit is unlimited. |
| Astro SSR, sessions, or Cloudflare bindings | Use the Astro Cloudflare adapter and a Worker-oriented deployment | Request-time behavior is a runtime decision, not just a static asset upload. |
For large content sites, also ask why every page is being pre-rendered. A lower file count can come from changing the rendering strategy, but that may introduce runtime CPU, caching, and routing requirements. Do not trade a file-count error for an untested SSR deployment.
Keep a static Astro build simple
Cloudflare’s Astro guide notes that a purely static Astro site does not need the Cloudflare adapter. Astro can generate dist/ and the host can serve those files as static assets. A minimal Workers Static Assets configuration is conceptually:
{ "$schema": "./node_modules/wrangler/config-schema.json", "name": "my-astro-site", "compatibility_date": "2026-08-17", "assets": { "directory": "./dist", "not_found_handling": "404-page" }}The assets.directory value must match the directory produced by your Astro build. The not_found_handling choice should match the routes you actually generate; a static content site should not use an SPA fallback merely to hide missing files.
If you keep using Pages on a paid plan, set PAGES_WRANGLER_MAJOR_VERSION=4 in the Pages project environment as Cloudflare documents. Merely installing a newer local CLI does not prove that the Pages build environment uses the setting required for the higher limit.
Migrate from Pages without mixing output models
Cloudflare’s Pages-to-Workers migration guide maps a Pages build output setting to an assets.directory entry and uses wrangler deploy for the Worker deployment. The migration checklist is:
- Record the current build command and the exact directory Pages uploads.
- Run
pnpm buildlocally and compare the resultingdist/tree. - Replace
pages_build_output_dirwithassets.directoryonly when the project is using Workers Static Assets. - Keep a deliberate
compatibility_dateand review preview URL behavior. - Deploy a non-production version and request representative HTML, CSS, image, and 404 paths.
- Switch the custom domain only after the generated URLs and redirects match the Pages deployment.
The migration guide was updated on August 14, 2026, but the values above are still deployment inputs that should be checked against the current Cloudflare documentation before a production change.
Do not use static assets for an SSR requirement
The Cloudflare adapter changes Astro’s output toward on-demand rendering. Use it when the site needs request-time logic, sessions, or bindings. The existing Astro Cloudflare session binding guide covers the separate case where a deploy creates an unexpected SESSION KV binding.
If the project is a content-heavy static site, inspect the generated data and chunking before selecting SSR. Astro content collection storage can reduce the risk of one oversized generated data file, but it does not change Cloudflare’s total static-file limit.
Takeaway
Count the deployed dist/ files first. Choose paid Pages or paid Workers Static Assets when the build fits below 100,000 files, and choose an Astro Worker only when request-time behavior is part of the requirement. Neither product removes the need to control generated output.
FAQ
Q: Is Cloudflare Workers Static Assets unlimited for a large Astro site?
A: No. Cloudflare currently documents 20,000 static asset files on Workers Free and 100,000 on paid plans. A large build still needs an output-count check.
Q: Does an Astro static site need @astrojs/cloudflare?
A: Not when Astro is generating a purely static site. The Cloudflare Astro guide says the adapter is for on-demand rendering; static output can be uploaded as assets. Use the adapter when the application needs SSR or bindings.
Q: Why does a paid Pages project still have a 20,000-file limit?
A: The higher Pages limit requires the documented PAGES_WRANGLER_MAJOR_VERSION=4 project environment setting. Check the deployed build environment rather than only the local package version.
References:
Report a typo or broken link, or suggest a related topic.