fhd / clostache

{{ mustache }} for Clojure
GNU Lesser General Public License v3.0
318 stars 62 forks source link

Template Caching for Clostache #25

Closed lorthos closed 11 years ago

lorthos commented 11 years ago

I am using a simple guava based caching implementation for avoiding IO to load templates on each request. (Sample: https://github.com/Rcmmndr/rcmmndr-clojure-sample/tree/master/src/rcmmndr) Do you think that this is worth to be integrated into clostache? I have put this feature inside a sample webapp now but i can fork and add to the codebase if this seems reasonable. What do you think?

Cheers

JulianBirch commented 11 years ago

Hi, not a maintainer, but my own take on this is: if I were to cache things, I'd prefer to use core.cache. Equally, I think it's easy enough to put together that you don't really need it in a library (read: I've already written something similar) . If I were to try to improve the performance, I'd try writing a version of render that returns a compiled function (probably not that hard, but definitely fiddly). Most node libraries seem to do something like that, and I'm hoping that at least one of them has tested that it's actually worth doing.

fhd commented 11 years ago

I'm with @JulianBirch here, caching is something that can done by the caller, using whatever approach they prefer. I've briefly looked into precompiling templates a few months ago and I fear it would be a substantial effort. I'd certainly merge a pull request that implements it while still passing the spec tests :smiley:

lorthos commented 11 years ago

fair enough :) i just wanted to bring up the subject because for some alternatives it is a bundled functionality. (stencil,scalate etc..) but it is simple to handle on the application as well

fhd commented 11 years ago

I'm not entirely sure about this, but I've always seen caching and rendering as two separate beasts. What would speed things up a bit is internal caching, but I considered that to be premature optimisation so far.