Notes posted by concept47RSS feed
You can actually pass in an expires_in option that sets how long Rails should show the fragment before deleting it so as an example …
<% cache('homepage_sidebar', :expires_in => 10.minutes) do %> <div> ... </div> <% end %>
So in your controller. You’d just do …
@posts = Posts.all if fragment_exists?('homepage_sidebar')
to avoid performing a pointless SQL query.
This is the way it is done now http://guides.rubyonrails.org/active_record_validations_callbacks.html#presence
Its supposed to be http caching, but Rails will actually cache the response to whatever you specified as the cache store, *as well*, but only if you specify :public => true. The default is filestore so it will try to write to tmp/cache.
Only a problem if you don’t have the proper permissions set, in that scenario your apache/nginx logs could fill up very quickly with “permission denied errors”
Full explanation is here http://blog.tonycode.com/archives/418