blog.eliotsykes.com

Icon

New Rails Page Cache plugin: for holeless/seamless page caching

For Missed Connections the sitemap and home page are cached on the filesystem and only refreshed periodically, after an event is fired in the app to say that missed connection ads have been created or deleted.

To make users lives a little easier, I never wanted them to make the request that generated one of these cached pages.  This isn’t quite how Rails page caching works out of the box.  Instead I wanted the page cache to be primed during deployment and periodically updated by a rake-task-calling cron job.

In Rails, out of the box, if a cached page is expired, it is deleted from the filesystem and is only generated when a new request comes in for that page.  This means the first person (could be more than one person if you get concurrent requests) to request the expired page will have to wait for it to be generated.

Instead, to save users’ time, I wanted the cache to be “holeless” (inspired by the Pivotal Labs post Rails, Slashdotted: no problem). To do this there is a cron job that generates new cached pages, and then replaces the old cached pages with these new cached pages.

In other words, the expired cached pages are only deleted after a refreshed version of the same page is available on the filesystem.

The first version of the plugin and README details are available at Github: Page Cache Rails Plugin

Category: Ruby on Rails

Tagged:

Leave a Reply

Who’s Blog?



Hello, I’m Eliot Sykes and this is my blog. Thank you for visiting. I'm the Founder of MissedConnections.com


Read about my current projects, contact me or find me on github