Wandering Thoughts archives


Dynamic rendering versus static rendering for websites

One of the long-standing splits for dynamic websites is between dynamic content rendering and static content rendering (where you use tricks like 404 handlers to generate a page's content only once, write it to a static file, and then afterwards just serve the static file).

(This assumes that static rendering is viable; for heavily personalized sites it may be more trouble than it's worth, if you are already effectively never generating the same page twice anyways.)

Fundamentally the choice is tradeoff of programmer time versus performance. A fully dynamic system behaves worse, requiring more resources to handle the same volume, but you don't have to deal with cache invalidation (and its close cousin, concurrent cache refill). Often this tradeoff is worth it, especially if you can shim in a simple caching layer to improve performance if you turn out to need it; most websites will never be hit with all that high a load, especially a load high enough that programmer time is cheaper than more hardware.

(The problem of cache invalidation in static rendering is that you need to keep track of all of the automatically generated static pages that your update may invalidate. For some websites, this is pretty easy; for others, it may be quite difficult. This may argue that websites, like programs, benefit from avoiding too many interconnections between their bits.)

Although I like the simplicity of dynamic rendering for my own work, I find the static rendering approach neat and cool, and in some ways it feels like the right thing to do (especially the extreme versions that pre-render your entire website). Plus, of course, it's got great performance.

(And it doesn't feel like cheating the way other sorts of caching sometimes do, partly because at the extreme it's no more a cache than make is. If anything, doing dynamic rendering of largely static websites is what feels like cheating, in that if I was smart and clever enough I could do it all with make and a static rendering engine; I do it dynamically because it's easier and I'm lazy.)

web/DynamicVsStaticRendering written at 22:42:44; Add Comment

Page tools: See As Normal.
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.