A lesson about client-side templating

The past few months have seen an explosion of client-side MVC frameworks. Wikipedia lists eleven of these things! And yet even a year ago the majority of developers was perfectly content with jQuery.
But as browser apps become ever more powerful it only makes sense to realize callback soup isn't fun and _hey, wasn't there some paradigm we use on servers to make this web insanity work? Yeah, there is.
A few months ago I gave a talk entitled Tools that get you laid at WebCamp Ljubljana. The basic premise was that client-side MVC is so insanely awesome you are sure to get laid for using it. The main benefits I talked about were:
- Server is just a DB interface, means less melting servers
- Effect similar to progressive loading, means users _see something immediately _- makes waiting easier
- Using powerful client machines to do the heavy UX lifting
- I may have had some other points :P
The lesson
The past four days have taught me an important lesson though - perhaps none of this is true.
Since Thursday my blog has seen two months' worth of normal traffic - more about the shiny stats tomorrow - it was only natural that poor ol' wordpress would crumble under the pressure ... right?
Well, actualy, no, it totally shouldn't have. There's all this fancy caching going on that what readers see are pretty much just static pages. There's no more PHP or server involved!

But none of that helped. Even redirecting the URL with most traffic straight to the stored static page didn't help. Something strange was happening. Something strange happens every single time this blog gets some traffic. This time it was particularly bad so I investigated.
Turns out the problem is in the small bit of client-side templating I do in my footer.
Because the pages are static, loading my latest foursquare checkin, the last four instagram pics, and the list of my github repos must happen client-side. It would be stupid to generate all this server-side every time somebody visits my site.
To achieve this I'm using jquery template, it's a bit archaic and I may have started working on the footer before finding out about backbone and other cool MVC frameworks ... but it works and it's so small I don't think it would even benefit much from using a framework. The basic premise of most javascript templating is simply substring replacement, like so:
<img title="${the_title}" src="${url_var}" alt="" />
Everything marked as a variable gets replaced with its value and everyone can be happy.
Try to guess what happens with that src="${url_var}" bit in there. Yep, the browser tries to load it. Firing a request to something that always returns at least a 404 after wordpress decides that, hey, this isn't something I know of!
This means that the url is never cached either server-side or client-side!
Turns out my blog was firing two such requests every time somebody came to the page. Every. Single. Time! In the latest case this meant 8 useless request per second at its peak. To the point most of my site just started throwing a 500 error and only that one redirected static page was still up ...
All I have to do now is find a permanent solution. Any ideas?