« IE7 Were they ready? | Main | MochiKit.Animator »

Caching Archetypes ImageFields with Squid

This is an issue that has cropped up on a couple of our sites. We generally only use Squid to cache images, javascript and css. Cached Javascript and CSS are not a problem in Plone, because the resource tools change the url of the javascript and css every time a new version is released. That way we can have extremely aggressive caching strategies for them.

Images are another matter however. We certainly don’t want to serve them from Zope if we can avoid it — but caching is a problem when the images are changed.

Enter CMFSquidTool. This patches the catalog reindexing hook to generate a sequence of PURGE commands to Squid, for the item being reindexed. This works great if you are using a single Archetypes object to store your content, but if you have anything like an ImageField it doesn’t work so well. You get a PURGE generated for your object, but not for it’s dependent images — which might be what changed.

So, I’ve pached CMFSquidTool to look for ImageFields in the object it’s purging, and generate additional PURGE commands for all images, and all of their different sized thumbnails. This works well, and solves what is otherwise a difficult issue.

I’d like to produce an adaptor-based solution for this - With an interface for objects and fields that says what purgable urls they have, if any, and adapters for the base Archetype object and it’s various fields. Does anyone know if anything like this exists already?

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)