07 September, 2023 by Yoan Arnaudov
• Category: Command line tools
I've been using Zsh with Oh-My-Zsh for a long time. All MacOS users have the Zsh (Z shell) installed and configured by default.
My Zsh configuration changes very rarely, but when it does, I need to restart my shell in order for my changes to take effect. Since I'm using tmux I can open a new window (which loads a new Zsh instance), but most of the time, I prefer to reload the current window.
To reload your Zsh (Z shell) .zshrc configuration, you can use the following command
01 September, 2023 by Yoan Arnaudov
• Category: Symfony
To return JSON response from Symfony Controller, you can use the $this->json(); method or new JsonResponse(['...']);
31 August, 2023 by Yoan Arnaudov
• Category: Cloudflare
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.