Cloudflare Unboxed

Cloudflare Unboxed

Share this post

Cloudflare Unboxed
Cloudflare Unboxed
How to proxy and cache a no-code Carrd site with a custom Cloudflare Worker

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

Rocco R.'s avatar
Rocco R.
Jun 14, 2025
1

Share this post

Cloudflare Unboxed
Cloudflare Unboxed
How to proxy and cache a no-code Carrd site with a custom Cloudflare Worker
Share

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.

Article content
Step 1: go to workers & pages
Article content
Step 2: start with hello world
Article content
Step 3: deploy (then we edit it)
Article content
Step 4: edit code
Article content
Step 5: Paste the code from the worker snippet below and deploy again

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:

  1. Carrd for quick iterations and zero backend

  2. 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.

1

Share this post

Cloudflare Unboxed
Cloudflare Unboxed
How to proxy and cache a no-code Carrd site with a custom Cloudflare Worker
Share
© 2025 Rocco R.
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share