# Time based expiration for fragment caching

**URL:** <https://www.ruby-forum.com/t/time-based-expiration-for-fragment-caching/149826>\
**Category:** Rails\
**Created:** [September 30, 2008, 10:51am UTC](https://www.ruby-forum.com/t/time-based-expiration-for-fragment-caching/149826 "2008-09-30T10:51:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![justus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b2d939/32.png) [@justus](https://www.ruby-forum.com/u/justus)\
**Post date:** [September 30, 2008, 10:51am UTC](https://www.ruby-forum.com/t/time-based-expiration-for-fragment-caching/149826/1 "2008-09-30T10:51:38Z")

</div>

Does anybody have any suggestions on how to do this? I have tried all  
kinds of plugins , googled all over the place but can’t get it to work  
for 2-3 days now:

I use simple fragement caching like this:  
\<% cache do %\>  
\<%= render :partial =\> @groups %\>  
\<% end %\>

and in the controller somthing like this:  
def index  
unless read\_fragment ‘index’  
fetch\_groups nil  
end  
end

THIS DOES WORK. I am able to expire this cache from the controller. I  
have not changed any of the default caching settings.

Now I am looking for a solution to achieve automatic time based  
expiration of such a fragment cache.(I didn’t get plugins like  
cache\_foo, timed\_fragment\_cached to work.) I think it might have to do  
with memcached issue. As a lrealtive newbie I am confused whether  
memcached is a.) needed for this b.) already installed by default or  
not.

Can anybody point me to a relatively easy way on how to do this?

Thanks so much!  
Justus

---

<div class="post-metadata">

**Author:** ![justus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b2d939/32.png) [@justus](https://www.ruby-forum.com/u/justus)\
**Post date:** [September 30, 2008, 12:59pm UTC](https://www.ruby-forum.com/t/time-based-expiration-for-fragment-caching/149826/2 "2008-09-30T12:59:14Z")

</div>

Ok, let me rephrase this:

Is there a simple way to do time based expiration for cached fragements  
WITHOUT using memcached?

Thanks,  
Justus
