Cloudflare


Expose your local server with Cloudflare Tunnels for free

Have you ever needed to expose your local web server to the public Internet? There are a lot of tools out there that will help you do that. Most of them have free versions with limited features and full-featured paid versions.

In this post, I'll demonstrate totally free method to expose your local webserver that is totally free with HTTPS support - Cloudflare Tunnels.

Cloudflare API purge cache by URL example

Cloudflare is a great free tool that offers static asset caching out of the box. You can also cache dynamic pages with it, which is quite handy.

Caching things is nice, but invalidating the cache is not a fun business. 

There is this popular quote:

There are only two hard things in Computer Science: cache invalidation and naming things.
-- Phil Karlton

I've done a little experiment with Cloudflare. I've configured caching in my blog. The post you are reading right now is cached in CF, currently with a TTL (Time to live) of 1 day.

After configuring the cache, a question immediately arose in my mind. If I update an article I'll need to wait for the cache to expire before the modifications become visible to the public, which is not ideal. I want immediate updates, but then I also want caching

So what is the solution? Simple - invalidate the cache each time the blog post is updated. Thankfully, Cloudflare offers free API, which allows you to do just that - purge cached content by URL. The documentation is not quite clear, and the method I've used is not documented 🤔, but it works, trust me.