Skip to main content
  1. Articles/

Cloudflare Workers

·
Ro'i Bandel
Author
Ro’i Bandel
Table of Contents
Static Website Hosting - This article is part of a series.
Part 2: This Article

Introduction

I have been considering different options for hosting static-sites for free. In my personal notes, I previously wrote about three differenet services for static website hosting: GitHub Pages, Cloudflare Pages and Codeberg Pages. Two of these options now have more modern alternatives: Grebedoc instead of Codeberg Pages and Cloudflare Workers instead of Cloudflare Pages.

Cloudflare Workers vs Cloudflare Pages

Although Cloudflare Pages is still around, since 2023 Cloudflare has been merging some of the features into Workers. Nowadays, while both Pages and Workers can be used, Workers is the preferred option (Migrate from Pages to Workers · Cloudflare Workers docs). Workers now has all the same static asset hosting features as Pages, plus additional features.

Pricing

In terms of pricing, Workers & Pages Pricing | Cloudflare lists the prices for both Workers and Pages. At first glance, the Workers Free tier appears to be more limited than Pages Free tier. Pages Free boasts “Unlimited sites”, “Unlimited requests” and “Unlimited bandwidth”, while Workers Free says “Includes 100k requests per day”, which is a far cry from “unlimited”. However, delving into the Cloudflare Worker docs, reveals the distinction:

Quote
  • Requests to static assets are free and unlimited. Requests to the Worker script (for example, in the case of SSR content) are billed according to Workers pricing. Refer to pricing for an example.
  • There is no additional cost for storing Assets.

Therefore, my understanding is that Cloudflare Workers is free and unlimited for static assets, and only costs money with requests to Worker scripts (importantly, clients loading static assets do not count as “requests”). This is essentially the same as Cloudflare Pages pricing, it only starts to potentially cost money if you go beyond what Pages can do and into other Worker features.

Why use Cloudflare Workers?

Despite today’s outage, I find Cloudflare to be generally reliable and use its free tier for most of my self-hosted websites and services. The only thing I pay for is domain registration, and domains are fairly priced (offered at cost). Many people have concerns over Cloudflare’s control of the web. I understand those concerns but it’s not something that I personally worry about. I enjoy taking advantage of their generous free tier either way.

Because I already use Cloudflare as my domain registrar, it makes sense to also take advantage of their static website hosting features and the included unlimited traffic.

Compared to GitHub Pages

Both Cloudflare Pages and Workers have less limitations than GitHub Pages. The most notable limitation of GitHub Pages that I can find is that the free tier of GitHub Pages and wikis only allows using “Public repositories”.

Compared to self-hosting

Self-hosting a website is possible as I have the infrastructure for it at home. After I completed the bootcamp, I kept my final project (PetInvent) up for several months on a self-hosted Docker Compose stack (PetInvent + PostgreSQL + nginx), which was running on my homelab along my other other self-hosted services. However, I don’t have the same uptime as Cloudflare. And even if I did, I still rely on Cloudflare anyway (Tunnels + domain), even for self-hosting. I might as well use their hosting as well if it doesn’t cost me anything.

Documentation

Some relevant pages from Cloudflare Workers docs:

Tip

Cloudflare Workers docs have guides for various frameworks which I am using or considering using, including React + Vite and Docusaurus. These guides can either be followed directly, or npm create cloudflare@latest can help bootstrap a project for various frameworks with correct Workers configurations.

Can I use Cloudflare Workers for my projects?

Based on the docs, Cloudflare Workers may be ideal for CALMe, which uses React + Vite for the frontend and Docusaurus for the documentation. My current goal is to set up a Continuous Deployment for CALMe, with the main branch deploying live to my FQDN on Cloudflare using Cloudflare Workers. After I get main working, I can setup a fancier CD flow with previews on pull requests.

For my personal website, I was leaning towards using Hugo, which works with Cloudflare Workers.


Featured image by Sharad Bhat on Unsplash.

Static Website Hosting - This article is part of a series.
Part 2: This Article

Related

Home Assistant on Kubernetes

·
Run Home Assistant on Kubernetes with the Helm chart, covering persistence, add-ons, replicas, and how it compares to Home Assistant OS for homelab smart home deployments.

Grebedoc

·
Today I learned about Grebedoc — static site hosting for git forges.

Git Setup for Windows and WSL

·
Configure Git once for both Windows and WSL: install Git and GCM, reuse your .gitconfig, and enable seamless credential handling across environments.