Theme Preview Caching

Post Information

Posted on October 16, 2010

By John Nunemaker

As we have mentioned before, everything for Harmony is stored in MongoDB. Yep, everything, including your assets, stylesheets, javascripts, images and theme previews. All of these things, save theme previews, were cached to the file system for faster reads. Tonight, I took a bit of time out of my Friday evening to code up and deploy theme preview caching, which means you may notice that the admin loads with a little more snap.

So why did caching theme previews make such a big difference in admin loading speed? Each time the admin does a full load (sign in, refresh, etc.), it grabs all of your sites and their previews and puts them in the site list at the top of the page. This gives you easy access to all your sites and is a great benefit of using Harmony.

The problem was all of those theme previews were being served through Rails and querying the database, which is far less efficient than serving them as normal static files through Apache. Now, once a theme preview is requested, it first checks the file system. If found, it serves the file through Apache and does not hit Rails. If not found, it hits Rails, caches the file, and serves it, so that all future requests for the preview go through Apache.

Nothing that will really blow your mind, but I hope you enjoy the slight speed up. I know I will sleep easier knowing that I can check one more thing off our ever growing todo list.