Hello all,
I''m starting to work with fragment caching. Caching is working fine.  
Expiration isn''t.
Vitals:
ActionController::Caching::Fragments::FileStore
Rails: -r5553. Also tested against edge (-r5662) with the same results
Relevant (abbreviated) code:
app/controllers/ssf_controller.rb
class SsfController < ApplicationController
   cache_sweeper :order_import_file_sweeper, :only => [:index]
   def index
	# non-cached stuff, including @campaign
     unless read_fragment(:action => ''index'')
       @results = @campaign.active_results
     end
   end
   # ...
end
app/views/ssf/index.rhtml
<!-- non-cached stuff -->
     <%- cache do -%>
     	<%- if @results -%>
	<table cellspacing="0" id="results">
     	<!-- big, expensive results table -->
	</table>
	    <%- end -%>
	<%- end -%>
<!-- more non-cached stuff -->
app/models/order_import_file_sweeper.rb
class OrderImportFileSweeper < ActionController::Caching::Sweeper
   observe OrderImportFile
   # If we import a new order import file, we want to expire cached
   # data based on OrderImportFile data
   def after_create(order_import_file)
     logger.error(%/OrderImportFileSweeper#after_create hook/)
     expire_trd_ssf_campaign_results
   end
   def after_update(order_import_file)
     logger.error(%/OrderImportFileSweeper#after_update hook/)
     expire_trd_ssf_campaign_results
   end
   def after_destroy(order_import_file)
     logger.error(%/OrderImportFileSweeper#after_destroy hook/)
     expire_trd_ssf_campaign_results
   end
   private
   def expire_trd_ssf_campaign_results
     logger.error(%/ 
OrderImportFileSweeper#expire_trd_ssf_campaign_results/)
     expire_fragment(:controller => "ssf", :action =>
''index'')
   end
   def logger
     RAILS_DEFAULT_LOGGER
   end
end
I''ve used logger.error to make it logs to both the production and  
development logs, not because it''s an error. I have  
config.action_controller.perform_caching = true in development.rb,  
and I can see that it''s caching from the speed of the response, the  
fact that cache files are showing up in my specified cache directory,  
and that the development log includes "Cached fragment:" and
"Read
fragment" messages. I''ve tried both production and development  
environments with the same results.
I can also see that the expire_trd_ssf_campaign_results method is  
being called, as logging I''m doing within the method is being written  
to the logs. However, the cached fragment isn''t being removed from  
the file system and I''m not seeing the cached fragment being refreshed.
What might I be doing wrong? What else should I be looking for?
Thanks for any and all advice and suggestions. Fragment caching looks  
to really improve the response time for some pages that involve  
pretty intense db queries in my app. I''d love to get it working :)
Michael Glaesemann
grzm seespotcode net
--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---