Time-based expiry of the Rails Page Cache

September 22nd, 2007 by Nikhil

Rails page caching is a great way to cope with a large number of hits. However, it’s hard to use in a typical web application cos parts of the page need to be personalized.

Even then, there are quite a few use cases where one could do a page cache for partials! Especially when using AJAX, the rendered partial at times is the same for all users. For example, when showing “related content”, the content displayed is related to the current article and not the viewer. In such a case one could use a page cache.

The only problem now is expiring the page cache. Computing “related content” is usually a time intensive operation when calculated from the other way, i.e. new content is added, so expire all pages to which it might be related to (so that it will appear as their related content the next time the partial is generated). Thus expiring the cache using sweepers isn’t an option. In such cases, a time based expiry works very well.

For this I have written a simple script using which you can specify which directory should be purged and at what time intervals.

Just download the cachedel script and drop it into your RAILS_ROOT/scripts directory

Then configure your cron to invoke it periodically.

Example:

0 * * * * /var/www/apps/c2w_portal/current/script/cachedel "blogs" 120This will invoke the cachedel script every hour and the script will delete all files in the blogs cache that are older than 2 hours

Commoditization of Software Engineering

November 22nd, 2006 by Nikhil

As any practice matures, it’s practitioners try to find ways to drive up efficiency, quality and reduce risks and costs. Generally speaking, this leads to better and cheaper products. However, IT services companies seem to be taking this concept a bit too far.

Most tech organizations evolve processes that try to be predictable, cost effective and at the same time less dependent on people. The process relies more on roles such that any person can be cast into it. The processes warrant that people be replaceable since they aren’t predicable. The process maps software development into and assembly line. (more…)

Self-Centered Software Design

November 13th, 2006 by Nikhil

Dog and CatIt’s well known that most software developers hate providing support, training end users, writing documentation, basically anything that doesn’t involve programming. But when you force them to do what they hate the most, you can expect dramatic improvements in the software that they create.
It’s kinda like If you are a dog who makes cat food, let the cats come to you if they need to throw-up.
(more…)

Microsoft’s Desktop Irony

November 10th, 2006 by Nikhil

Steve Ballmer is currently in India and has made the headlines of todays Economic Times. Apart from the usual Google/Oracle/Apple/IBM bashing, he vehemently defends the desktop. That’s logical since Microsoft’s main moolah generating engine is powered by the desktop. Isn’t it then ironic, that the one innovative thing to come out of Microsoft - XMLHTTPRequest (backbone of AJAX), is directly aimed at reducing the desktop to merely a device sporting a terminal, keyboard and mouse. (more…)

In defense of J2EE’s complexity

November 7th, 2006 by Nikhil

EinsteinJ2EE bashing seems to be the flavour these days. While I do agree that J2EE does seem tedious at times, especially when you compare it with the likes of Ruby on Rails, I still realize (and appreciate) why and how J2EE got to be the way it is.

(more…)

Ruby, A Samurai’s Sword

November 5th, 2006 by Nikhil

KatanaI like to think of Ruby as a weapon. A weapon with which I can attack problems my way! Ruby appears simple, and convenient, and hence poses a question; Why aren’t enough techies using it?

That’s when I realized - Ruby is like a Samurai’s sword, a Katana. Not of much use to the corporate coder, but in the right hands, extremely effective. (more…)

Future of Enterprise Content Management

October 6th, 2006 by Nikhil

An Information System’s key purpose is to manage and serve information to it’s users. Thus information storage and retrieval is at the heart of any IT system. Most systems use Relational Databases (RDBMS) for this purpose.

As technology matures, software development tools progress towards working in the business domain. As an example, programming languages have come a long way from machine code to assembly language to procedural languages and now to object-oriented languages and 4GL. I don’t see why data storage, retrieval and management shouldn’t follow the same evolution cycle. In the past developers used punched cards, followed by flat files and moved to relational databases for data storage and have been stuck at relational databases for around 20 years now. (more…)