Chrome showing cached JSON after navigating to new page and hitting back button using Ruby on Rails as backend Chrome showing cached JSON after navigating to new page and hitting back button using Ruby on Rails as backend google-chrome google-chrome

Chrome showing cached JSON after navigating to new page and hitting back button using Ruby on Rails as backend


Looks like the answer was turning off caching of the JSON or convincing Chrome that the cached JSON wasn't what was wanted. Based on another question's answer, I added response.headers['Vary'] = 'Accept' in the rails controller when returning JSON.

So, in context:

respond_to do |format|  format.html do     render :template => xxx  end  format.json do    response.headers['Vary'] = 'Accept'    render :json => {...}  endend

Questions that helped me: