Name can take one of three forms:
- String: This would normally take the form of a path like "pages/45/notes"
- Hash: Is treated as an implicit call to url_for, like { :controller => "pages", :action => "notes", :id => 45 }
- Regexp: Will destroy all the matched fragments, example:
%r{pages/\d*/notes}
Ensure you do not specify start and finish in the regex (^$) because the actual filename matched looks like ./cache/filename/path.cache Regexp expiration is only supported on caches that can iterate over all keys (unlike memcached).
Source Code
# File action_controller/caching/fragments.rb, line 110 def expire_fragment(key, options = nil) return unless cache_configured? key = key.is_a?(Regexp) ? key : fragment_cache_key(key) if key.is_a?(Regexp) self.class.benchmark "Expired fragments matching: #{key.source}" do cache_store.delete_matched(key, options) end else self.class.benchmark "Expired fragment: #{key}" do cache_store.delete(key, options) end end end
<code/>and<pre/>for code samples.