Fragment cache expiry problem

Hi,

I’ve been wrestling with various different caching options for the last
couple of days and am stuck with one specific problem, to which I can’t
find any clues anywhere.

Here is the essence of it:

What would cause fragment caching to constantly expire by default?

And here are some details:

I have an index page which has some content that is populated by a call
to an external service. Since this content changes once every couple of
minutes, I need to cache in a way which will expire automatically after
2 minutes. The rest of the page stays the same between one deployment
and the next, so my plan was to cache the page in 3 fragments: 2 of
which contain content which doesn’t change, and 1 of which contains the
dynamic content. Since Rails unfortunately lacks any facilities for
timed cache expiry by default, I was going to use the
timed_fragment_cache plugin
(http://livsey.org/2006/8/25/timed_fragment_cache-plugin-fragment-caching-with-time-based-expiry/)
to expire the cache of this dynamic fragment.

The fragments are produced just as they should be when a page is first
called up, and they are read when the page is called again. The only
problem is that they are expired immediately, which means that the cache
gets expired and rebuilt with every single request, which obviously
makes the cache completely pointless!!

My initial thought was that this must be a bug introduced by the
timed_fragment_cache plugin. However, even after uninstalling this
plugin I still have the same problem. The question is, why are these
fragments expiring at all? A fragment that is cached should stay the
same until it is specifically made to expire. What could there be that
might cause it to expire without any prompting?

It even doesn’t work when I wrap the whole index action in an:

unless read_fragment…

Rather, what happens here is that the code in the index action only gets
executed the first time the page is requested, but the cache itself gets
expired and rebuilt on every further request. This means that the page
content appears once and then vanishes! So, my application is
recognising that there is a cached version of the page, and acting
accordingly, but still expiring and rebuilding the fragment.

Any ideas?

Thanks,

Rob.