4 ms·
Honestly, I don't know. I've never measured because it's never been a problem. Most of it is writing string literals to an io.Writer, no idea what the overhead
by markusw 3y ago
Honestly, I don't know. I've never measured because it's never been a problem. Most of it is writing string literals to an io.Writer, no idea what the overhead is there. Could be fun to write some benchmarks. :)
With regard to caching, I think I would opt for a solution at a different layer. For example, render the page and just cache the output in memcached, Redis or similar. Or just in memory maybe. As always, it depends.
- everforward 3y ago> With regard to caching, I think I would opt for a solution at a different layer. For example, render the page and just cache the output in memcached, Redis or similar. Or just in memory maybe. As always, it depends. I totally get that, it is dramatically simpler and it probably does well enough for most things. My theory was that you can effectively cache parts of a page, and then build pages out of the cache. Like if my page relies on a user ID and some kind of "is logged in" boolean, the "is logged in" parts have probably already been rendered before so we only have to dynamically render the parts that rely on this user ID (presuming we haven't seen this user ID and cached those parts already). Caching the whole page requires rendering both the user ID and the "is logged in" part, because it caches over the totality of the parameters. Now that I'm writing this out, it does seem a touch excessive lol. It's kind of like server side React, but I'd probably rather push that processing onto the client device because I don't pay for their CPU cycles.