jaspervdj / hakyll

A static website compiler library in Haskell
jaspervdj.be/hakyll
Other
2.69k stars 409 forks source link

How does caching work? #467

Open bergus opened 8 years ago

bergus commented 8 years ago

(related to #383) I've seen you can use cached, but unfortunately it is undocumented :-( What does it do, how does it work?

I'd love to see docs for cached or even an (advanced) tutorial article about caching in Hakyll in general (what is put in _cache etc). If some of the steps above are not implemented, would it be possible to add them?

Vtec234 commented 5 years ago

Something that works for me (or at least seems to work, so far) is that cached can be used to store (well, cache) partial compilation results. For example, pandoc compilation takes a long time, while applying templates is almost instant. I don't want to wait for pandoc every time I change a template, so I can do this:

    compile $ cached "pandoc" pandocCompiler
      >>= loadAndApplyTemplate "templates/post.html"  postCtx
      >>= loadAndApplyTemplate "templates/default.html" postCtx
      >>= relativizeUrls

Then changing templates/post.html will reuse the cached results from pandoc and rebuild quickly.