I have a Ruby on Rails website.
class DefinitionsController < ApplicationController
caches_page :index
def index
responds_to do |format|
format.json { render json: @something}
end
end
end
When I hit myapp.host.com/definitions.json I get my json data.
However when I call a function that uses expire_page :action => :index I won’t get a fresh update of that data, it keeps getting serving the old json file from the public dir. Another url of the website that also gets expired, but is a normal page, does come up fresh then.
I use Rails 3, hosting using Nginx and Passenger. When I run it using rails server it does work ok, so it must be something with Nginx or Passenger.
Is there something special I need to do, like call format => :json on the expire call?
I believe the problem is that you haven’t told
expire_pagethe format of the cached content, so it assumes html. Finding no cached html content, it simply does nothing.Try
expire_page :action => :index, :format => 'json'.