2026-10-15
cloudflare
Redirect limits on Cloudflare Pages
Lesson: after the first * or :slug rule, every rule counts as dynamic, and Pages ignores everything past 100 dynamic rules, with no error. Static rules go at the top.
/old-post /new-post 301 # static: keep up here
/2024/:month/:slug https://blog.example.com/posts/:slug/ 301 # dynamic: last
2026-10-15
cloudflare
Returning a 404 from Cloudflare Pages
Lesson: _redirects can't return a 404, only 200 and 301–308. To hide internal files, route them to a Function with _routes.json and serve the 404 page with status 404.
// functions/_middleware.js
export async function onRequest({ request, env }) {
const page = await env.ASSETS.fetch(new URL('/404', request.url));
return new Response(page.body, { status: 404 });
}
2026-10-15
web
Stale shared scripts after a deploy
Lesson: a hash of the file's content in its URL beats cache headers. A new version is a new URL, so nothing waits for the cache to expire.
<script src="/progress.js?v=418356486b"></script>