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:
- JSON breaking back button in Chrome, Reload Button in IE (Showing as naked data)
- Another I can't seem to relocate that suggested the 'Vary' header