You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Christopher Cocchi-Perrier edited this page Jun 6, 2013
·
4 revisions
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
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.