views:

33

answers:

1

Hi guy,

I would like to cache my fragment page in my rails application by time.

I found this plugin to do this => ici but any download is available.

I searched in the rails doc but I don't found how to cache my fragment by time.

Are you know another plugin to do this or another method to do this ?

Thanks.

+2  A: 

Creating a time-based cache key is quite simple. Here's an example.

Now in your app you can write

<% cache :expires => CacheKey.expirable(:hour) do %>
  ...
<% end %>

If you want a more accurate control (for example 5.minutes instead of simply 1 minute), you can easily adapt the module in order to dynamically generate the cache key reading the time value passed as parameter.

An other approach is to check the last-modified time of the cache file. Here's a plugin.

Simone Carletti
Thanks for your help, I try this asap.
Kiva