# Does Rails 3 provide time based caching?

**URL:** <https://www.ruby-forum.com/t/does-rails-3-provide-time-based-caching/193902>\
**Category:** Rails\
**Created:** [August 26, 2010, 12:33pm UTC](https://www.ruby-forum.com/t/does-rails-3-provide-time-based-caching/193902 "2010-08-26T12:33:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lexer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a8b319/32.png) [@lexer](https://www.ruby-forum.com/u/lexer)\
**Post date:** [August 26, 2010, 12:33pm UTC](https://www.ruby-forum.com/t/does-rails-3-provide-time-based-caching/193902/1 "2010-08-26T12:33:47Z")

</div>

Hi guys,

I need a timebased caching of certain pages. Cache for certain page  
should be cleared each 15 minutes. Is that possible?

In [http://edgeguides.rubyonrails.org/caching\_with\_rails.html](http://edgeguides.rubyonrails.org/caching_with_rails.html) manual I  
see that there is only manual cache clear methods, such as expire\_page  
or expire\_action.

Regards,  
Alexey

---

<div class="post-metadata">

**Author:** ![lexer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a8b319/32.png) [@lexer](https://www.ruby-forum.com/u/lexer)\
**Post date:** [August 26, 2010, 7:24pm UTC](https://www.ruby-forum.com/t/does-rails-3-provide-time-based-caching/193902/2 "2010-08-26T19:24:11Z")

</div>

On Aug 26, 6:33 am, lexer [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Alexey  
> I don’t think Rails provides time based caching. I also do not think  
> it’s needed. What are you trying to accomplish?

Lets say you have a page with list of products that you want to cache.  
The cache _only_ needs to be updated if one of the products changes.  
Caching the page for an arbitrary amount of time is unnecessary.

If you _really_ need a time based cache, you could just use a cache,  
then set the expire action as a cron job that runs every 15 minutes.

But really, infinite caching with proper expiration is the way to go.

---

<div class="post-metadata">

**Author:** ![lexer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a8b319/32.png) [@lexer](https://www.ruby-forum.com/u/lexer)\
**Post date:** [August 26, 2010, 9:35pm UTC](https://www.ruby-forum.com/t/does-rails-3-provide-time-based-caching/193902/3 "2010-08-26T21:35:55Z")

</div>

This depends on the cache store you use. The memcached store can  
expire cache items after a certain time.

See point 4 here:

> **[Caching with Rails: An Overview — Ruby on Rails Guides](https://guides.rubyonrails.org/caching_with_rails.html#cache-stores)**
>
> Caching with Rails: An OverviewThis guide is an introduction to speeding up your Rails application with caching.Caching means to store content generated during the request-response cycle and to reuse it when responding to similar requests.Caching is...
