Wasteful Computation

, Wellesley, MA

Why would you do the same thing millions of times when you can do it once?

When I read your blog, your servers route the link to a request handler, The request handler queries your database, renders a template with the data, and transfers the resulting document to my browser. Tomorrow, when I refer back to the same post again, your servers execute the request handler again, they query your database again, they render the template again, and they transfer the document again. If your article changes between today and tomorrow, that’s a great idea. But if it doesn’t, your servers are doing unnecessary work. Multiply that by however many users you have, and the costs of computation and operational complexity can add up.

Most blog posts never change after they’re written, but your software still renders them at request time. Why not render posts at publication time and repeat only the data transfer at request time?

Enjoyed reading this post? Discuss it on Reddit, or follow me on Twitter.