This project is archived and is in readonly mode.

#3677 open
Ary Djmal

Add support to action-cache json requests wrapped in a callback (jsonp)

Reported by Ary Djmal | January 9th, 2010 @ 10:41 PM

Given the following controller:

class PostsController < ApplicationController
  caches_action :index

  def index
    @posts = Post.all
    render :json => @posts, :callback => params[:callback]
  end
end

It's not possible to successfully cache json requests with callbacks (jsonp) because of the nature of how callbacks work.

This patch modifies the caches_action around filter by resetting the callback before rendering the fragment if it's a json request.

NOTE: This implementation saves the fragment with callback and reset it on read. Another implementation could be to remove the callback on save, and add (if necessary) on read.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages