Smashing Magazine featured an article, Going Serverless with Cloudflare Workers by Leonardo Losoviz. He mentioned about static site generators like: Jekyl, Hugo, or Gatsby. I’m not sure if Leonardo, in a general sense, just correlated these platforms with serverless approach to hosting or if the workflows of those static site generators are doable in CF Workers.
The deployment normally would look like this:
- Static generator will build site. Content will be sourced from a database or third-party APIs and generates static html files and other assets.
- The static files including html are hosted via CDN.
- If there are code changes go to number one.
- If there are content changes go to number one.
Normally the building process and deployment are done manually from a local machine. There are cloud providers that can do the rebuilding process automatically via webhooks or timed event triggers, e.g: periodic batching after authors have finalised a number of articles for publishing to the web.
I’d like to know what sort of topology would be involved if these processes were to be done with Cloudflare CDN and Cloudflare Workers. I understand that bit that Workers can be used as API gateway and executing JS functions but getting up the whole website running via workers is a blurry. So here are my questions:
- Would Cloudflare Workers platform be a one-stop shop place to host the pre-build files and deploy a website (as described above)? No?
If the answer to the above is no:
- If we have to host the static files outside of Cloudflare Workers (example here), and when content is pulled from the originating server – will they be automatically cached in CF’s CDN?
- In relation to the first bullet point, will Page Rules then kick in?
- Can you please confirm my understanding that we can mix api and website calls in one worker script?
Appreciate your thoughts. Please be kind, I’m new to serverless approach.