Invalidate Single URLs in Rack::Cache/Radiant::Cache

Posted on 12 January 2010 by Johannes Fahrenkrug. Tags: Programming Ruby rails
I've recently encountered a problem with Rack::Cache: I have a Radiant app with some custom extensions and some of those extensions build pages that are expensive to build. So far I could only purge the cache completely by removing the tmp/cache directory. That's not a nice solution if all I want to invalidate is one page. So after some digging I came up with this tiny script:

It allows me to explicitly purge certain URLs from my Rack::Cache based Radiant::Cache. Please note that this only works if you use the Radiant::Cache standard options. Otherwise you'll have to tweak the metastore that should be used.
Some further reading:


Jim Gay said...

Sorry, you're right. I quickly scanned this thread and thought it was pulled in

Thanks for making the issue.

January 12, 2010 04:41 PM

Johannes Fahrenkrug said...

Hey Jim,

are you sure about that? I studied the Rack::Cache code today and Sven Fuchs' purge stuff has not been merged yet. I even talked to Ryan Tomayko on Twitter today and he said that he hasn't gotten around to merging that stuff yet.

Also, Sven Fuchs' approach uses the HTTP PURGE verb, so you purge entries by making HTTP requests. I would personally prefer an API I can use programatically.

I will open a ticket, though!

- Johannes

January 12, 2010 03:51 PM

Jim Gay said...

The latest version of rack-cache has this feature built in. Create an issue for this on github and we can get per-key purging built-in

January 12, 2010 03:13 PM


Please keep it clean, everybody. Comments with profanity will be deleted.

blog comments powered by Disqus