How to proxy and cache a no-code Carrd site with a custom Cloudflare Worker
How to proxy and cache a no-code static website with a custom Cloudflare Worker
I like to move fast. Carrd.co is one of the fastest ways to get something online for simple landing pages. But it's no-code, and that usually means:
No control over webpage headers;
No granular cache rules;
No edge logic;
So I fixed that with a Cloudflare Worker that proxies and caches my static site at the edge.
Now I get:
Edge caching with fine-tuned TTL (time to live of the webpage);
Full control over web headers (CSP, security, performance tweaks);
A clean custom domain setup without relying on Carrd’s DNS or redirect hacks;
Here’s the idea:
Deploy your Carrd site like usual. Use the Carrd subdomain (e.g. https://yourproject.carrd.co).
Write a custom Cloudflare Worker to proxy that site.
Use Cloudflare’s Cache API inside the worker to serve cached responses when available.
Customize headers and cache rules.
Point your domain to the worker.
The Worker Snippet (just the handler as it is supposed to be)
async function handle(request) {
const cache = caches.default;
const url = new URL(request.url);
// Rewrite URL to point to the Carrd subdomain
const targetUrl = `https://yourproject.carrd.co${url.pathname}`;
const cacheKey = new Request(request.url, request);
let response = await cache.match(cacheKey);
if (!response) {
response = await fetch(targetUrl, {
method: request.method,
headers: request.headers,
});
// Clone response to modify headers and cache
let newHeaders = new Headers(response.headers);
newHeaders.set('Cache-Control', 'public, max-age=86400');
response = new Response(response.body, {
status: response.status,
statusText: response.statusText,
headers: newHeaders,
});
// Put response in cache
event.waitUntil(cache.put(cacheKey, response.clone()));
}
return response;
}
Why Bother?
Because I get the best of both worlds:
Carrd for quick iterations and zero backend
Cloudflare for speed, cache control, and flexibility
It also future-proofs the setup. If I switch from Carrd to a static site generator later, the edge proxy logic doesn’t need to change.
It’s boring infrastructure that makes my stack cleaner.
Let me know if you want a version that adds extra headers for SEO, HSTS, or security (X-Frame-Options, CSP, etc.).
Want more like this? Follow or subscribe. I publish fast fixes and clean dev hacks without the fluff.
This is Cloudflare Unboxed.