The Dopefly Tech Blog

« The Dopefly Tech Blog Main page

How Dopefly almost stayed alive

posted under category: ColdFusion on August 2, 2005 by Nathan

So Dopefly's web host decided to upgrade their servers without telling anyone. Wasn't that special? Glad to have my site back up, and apparently without losing anything in the process. That's a relief. I know, I know, I get what I paid for, but I'm happy (enough) with my $5/mo cf host. Yes they're terrible, and totally unreliable, but it's kind of an adventure, not being able to rely on databases and servers.

The site was actually up for 3 of the 4 days without a database, and yes, this is a fairly heavily data-driven site. How is it possible you might ask? Through the wonders of scope caching. Somehow when I built this site, I knew this would happen, so I'm glad to see it's paid off.

Now normally, a CF Cached query will time out at a certain time, or worse, never, without clearing all the cached queries on the server. With a good scope caching strategy, you can save recordsets in the application scope until the scope is cleared.

What I did was save my data in my query caching CFC, with regular interval timeouts (like 24 hours). If the query errored, I would increase the timeout by a minute and return the previously cached version.

Another advantage of this strategy is the ability to remove any cached entries when an update is made. When I click the submit button on my blog form, it inserts the record for this entry and invalidates my cached recordsets that will be affected by the change. The result is an instant update to would-be cached data.

Now the reason why Dopefly was down yesterday was because they reset the CF server. There goes my cached application data and my site. So now I'm devising a strategy to persist my cached data to disk (evil grin).

I know, I know, "Geez Nate, get a better host." But it's kind of exciting, living on the edge.

Nathan is a software developer at The Boeing Company in Charleston, SC. He is essentially a big programming nerd. Really, you could say that makes him a nerd among nerds. Aside from making software for the web, he plays with tech toys and likes to think about programming's big picture while speaking at conferences and generally impressing people with massive nerdiness and straight-faced sarcastic humor. Nathan got his programming start writing batch files in DOS. It should go without saying, but these thought and opinions have nothing to do with Boeing in any way.
This blog is also available as an RSS 2.0 feed. Click your heels together and click here to contact Nathan.