Looks like you could now easily do fragment caching with Jbuilder. Here's an example I found in jbuilder's source:
Example:
json.cache! ['v1', @person], :expires_in => 10.minutes do |json|
json.extract! @person, :name, :age
end
Applying this to your code, we will retain the following code in your controller:
gon.jbuilder template: 'path/to/template.json.jbuilder'
Then inside your jbuilder view, we'll do the fragment caching:
#path/to/template.json.jbuilder
json.cache! ['v1', @model], :expires_in => 10.minutes do |json|
#your template.json.juilder code in here
end
Let me know if it helps!