We use a REST-like web service to communicate with a large Endeca index. This web service is stateless and uses JSON. Unfortunately, its performance leaves much to be desired and the server does not cache requests. Fortunately, even with its weak implementation of REST, the service’s statelessness makes it trivial to add a caching layer to our client.
Rather than write our own caching solution, we looked to reuse one that already exists. No NIH for us. The caching provided by ActiveSupport::Cache turned out to be perfect for our needs and darn simple to implement. The end result is that web services requests that took from 200ms to 500ms and sometimes more (I told you it was slow) are now cache retrievals that take from 2ms to 5ms. That’s 10,000% faster. From 20 lines of code. With all the power and flexibility of the caching already built in to Rails. Winnage.