There are 2 levels of caching in rabl-rails
:
The first one is template caching. If this option is enabled, each file is only parsed and compiled once. The internal resulting of its compilation is cached, with the path as cache key. This process only saves compilation time (since ActionView already avoid to his the disk twice). By default this option is set to true
The second one is response caching. When this option is enabled, the full response (JSON, XML,) is cached within the cache backend configured with Rails. To enable it, just add the cache
keyword in your template. For example
# posts/show.json.rabl object :@post cache { |p| "posts/#{p.id}" } attributes :title, :body
By default, is no cache_key is specified, the #cache_key
method will be called on the rendered object.
If nothing has been cached previously, it will render the template normally and cache the result. The next time it will hit the cache, response will be directly returned from the cache (thus being very quick).
If a partial template with a cache
directive is included via extends
, it will be ignored, only the full response can be cached.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4