Ticket #5 (new enhancement)
Rails fragment caching for Markaby!
| Reported by: | murphy@… | Owned by: | tec |
|---|---|---|---|
| Priority: | critical | Milestone: | 1.0 |
| Component: | lib | Version: | 0.5 |
| Keywords: | caching cache rails | Cc: |
Description
I've found out how to get caching working. So proud.
Reason
Caching Markaby is interesting for speeding up applications. By caching the static header of my site, I got 30% more req/sec.
The new cache method has the same interface as the standard one for rhtml templates. It only links to Rails' caching system.
Example
cache :controller => 'main', :action => 'logo' do
td.logo do
link_to capture { image_tag(logo, :id => 'logo') }, home_url
end
end
What's changed
The file attached (lib/markaby/cache.rb) adds a Builder#cache method that calls a variant of cache_erb_fragment, namely cache_markaby_fragment.
It should be required by the init.rb. Without Rails, it is not loadable.
Compatibility
It is working with 0.4 and with the xhtml-careful branch as well.
Tests & Docs
Code is commented, but I didn't add a test case - difficult to do without Rails in the package.
Problems
Calling cache without Rails would produce an unwanted <cache> tag. You could add a cache method then that ignores its arguments and calls the block.