⚠️ Archived Post
This is an archived post from my previous blog (2007-2014). It may contain outdated information, broken links, or deprecated technical content. For current writing, please see the main Writing section.

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

Originally published on January 12, 2010

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: http://github.com/svenfuchs/rack-cache-purge.

Comments

Jim Gay said...

Sorry, you're right. I quickly scanned this thread and thought it was pulled in
http://groups.google.com/group/rack-cache/browse_thread/thread/14ad1fd0c370b235/6ce1a2eb090f8527?lnk=raot

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