Well, this post is a bit verbose before I get to the actual question, so the shortened version mainly refers to heating the cache using RABL templates. When calling Rabl.render vs API calls, the generated caches do not have the same cache keys. When using Rabl.render directly, should you expect cache keys to match when the same template is called through the API?
K, now the completion ..
I have a Rails API server on Heroku. I did a lot of optimization using RABL using Russian doll caching to improve the reuse of base objects in collections. However, I still remain with caches for the collection, which when the user generates the first request, the burden depends on experience (for example, 1+ second api calls).
When debugging a sample API request, I get the following cache actions for this object.
... api / v1 / activities / 26600:
Cache read: rabl/activities/26600-20140423170223588554000//hash/d30440d18014c72014a05319af0626f7
Cache generate: rabl/activities/26600-20140423170223588554000//hash/d30440d18014c72014a05319af0626f7
Cache write: rabl/activities/26600-20140423170223588554000//hash/d30440d18014c72014a05319af0626f7
, so for the same object when calling ... api / v1 / actions (after calling above) I get the desired cache click:
Cache read: rabl/activities/26600-20140423170223588554000//hash/d30440d18014c72014a05319af0626f7
Cache fetch_hit: rabl/activities/26600-20140423170223588554000//hash/d30440d18014c72014a05319af0626f7
. - , / API .
, . wget API (. qaru.site/questions/297126/...). - Heroku, , .
RABL (https://github.com/nesquena/rabl#rendering-templates-directly), , RABL- - API (, ).
, API rails , .
irb(main):002:0> @activity = Activity.find(26600)
irb(main):003:0> Rabl.render(@activity, 'api/v2/activities/show_no_root', :view_path => 'app/views', :format => :json)
Cache read: rabl/activities/26600-20140423170223588554000
Cache generate: rabl/activities/26600-20140423170223588554000
Cache write: rabl/activities/26600-20140423170223588554000
, -, , - -. , . RABL.
-, .
Cache digest for api/v1/activities/_show.rabl: d30440d18014c72014a05319af0626f7
, , Rabl::Renderer .