Matt Fordham
Matt Fordham

Reputation: 3187

How to time expire Rails fragment caches?

How would I go about expiring a fragment cache after a period of time. I came across references to a timed_fragment_cache gem, but it seems out-dated.

Upvotes: 33

Views: 13307

Answers (1)

Alex
Alex

Reputation: 9481

Using ActiveSupport::Cache::Store, you should be able to do

<% cache(key, expires_in: 1.hour) do %>
   <!-- content -->
<% end %>

Upvotes: 89

Related Questions