You can use your Mastodon account to reply to this post.
… but it can be a bit slow sometimes. Lately, I experienced total build times of ~10 mins for my very simple blog. This is annoying when I want to fix a small typo (which happens quite often). Even on a good day the build on GitHub takes ~1 min. In contrast, on my local machine a new post is build in less than 1 sec. How is this possible?
GitHub Actions always start on a green field. One every execution, it fetches a more or less empty Ubuntu image. Then Hugo must be installed (as snap) on this fresh Ubuntu instance. Afterwards, Hugo translates all files into static HTML pages. Finally, the files are
rsynced to my server. While the last step is very fast, all other steps take several seconds. These seconds add up to roughly a minute. When GitHub is busy serving other customers, it becomes even slower.
When I run
hugo locally, the first run takes several seconds. On each following execution Hugo will just translate new posts (normally just one post). All old files remain untouched. So a local run is much cheaper on resources and therefore much faster. Usually, I see build times around 100 milliseconds.
So far my webserver was very dumb. It just served HTML/CSS/JS files, but had no idea how these files are shipped to the server. All processing happened on other machines. In the end, the final result just magically appeared on my caddy server. Much like when you order a new book on Amazon. The complexity of writing, printing and shipping a book is completly hidden from you.
I spent half a day to smarten up my server and the overall flow now looks like this
POSTrequest to a given URL
git pullon my blog repo on github
touch blog_refreshed.txtwrites an empty file, so the file update date is equal to the latest blog refresh
With this new setup my blog updates happen instantly. Basically, my server executes the same steps that I would do locally. Therefore, the build is as fast as on my local machine. :D
I will publish another post detailing the setup, soon.
Stay tuned, ladies and gentlemen.