I have an Ruby on Rails application where fragment caching is used and using memcached for storing the data.Also i have a sweeper which expires the cache when changes are made to the model.
index.html.erb
<% cache 'recent_albums' do %>
contents to be cached
<%end %>
class AlbumsSweeper < ActionController::Caching::Sweeper
observe Album
def after_save(album)
expire_cache(album)
end
def after_destroy(album)
expire_cache(album)
end
def expire_cache(album)
expire_fragment 'recent_albums'
end
end
I have a requirement where before the user hits the Albums page the expired fragment needs to be refreshed with the new data. Can someone please help on how the fragment cache data refresh can be implemented?