This one has been a long time coming! Bascule only takes a few seconds to generate this website, but I've always wanted it to be faster. As the number of blog posts grows, Bascule will inevitably get slower. I can't do a lot to improve the rendering of individual web pages - that's mostly handled by third-party libraries - but I can be more selective in deciding what pages are rendered. After all, in a typical website, most pages don't change much at all. And in a blog, it's quite feasible that only a new blog post needs to be generated.
So I've been very keen to implement a caching mechanism for Bascule. It's taking me longer than I had hoped, with several false starts. For a while I thought I had it working, but my implementation broke the generation of non-blog pages, including, crucially, the index page. In trying to understand why, I decided to write more unit tests - and that revealed just how untestable the Bascule code was.
A major rewrite was needed, and I think Bascule is in a healthier state now. And crucially, caching now works. By default, Bascule will only regenerate the pages which have changed since the last generation, based on the last modified date and file size of the source markdown file. During generation, a cache file (in JSON format) is generated and saved in the project sources folder (named <projectname>.cache.json
). The application compares each markdown file with the cache item; if the source has been modified, or a new source file is found, the cache entry is updated and the file is added to the set to be regenerated.
If you ever want to bypass the cache, simply add the -c
clean flag to the command:
java -jar bascule.jar generate -c
In a blogging scenario, you'd expect the website homepage to be regenerated when a new blog post is written, and this is handled in Bascule. Making this work has been a lot of effort and I'm still fine-tuning it.
I have merged the caching pull request into the master branch, through there are still a few bits and bobs to sort out. Importantly, the cache pays no attention to the page templates written in Handlebars - if the template changes, but no markdown file has been updated, no files will be regenerated. Let's call that a pending feature request - and in the meantime, feel free to use the -c
clean flag.