Big problem with returning json data
I have a controller action that returns a json structure.
render :json => hash_data
It works for a small dataset in both production and development modes. However, for a large dataset, this only works in design mode. In production mode, only part of the json string is returned. Rails version 3.0.9. In production mode: goes from load balancing to nginx; in development mode: I am using webrick.
Production Mode Http Response Header:
Cache-Control max-age=0, private, must-revalidate
Connection close
Etag "a7b077a364f849a57ffe582525c98ea1"
Server nginx/1.0.10 + Phusion Passenger 3.0.11 (mod_rails/mod_rack)
Status 304
X-Powered-By Phusion Passenger (mod_rails/mod_rack) 3.0.11
X-Runtime 8.462971
X-UA-Compatible IE=Edge,chrome=1
Http Response Header Development Mode:
Cache-Control max-age=0, private, must-revalidate
Connection Keep-Alive
Content-Length 144561
Content-Type application/json; charset=utf-8
Date Tue, 20 Mar 2012 08:37:30 GMT
Etag "b6b9cdb7811577280320f7a3f50bd937"
Server WEBrick/1.3.1 (Ruby/1.9.2/2010-08-18)
X-Runtime 12.832829
X-UA-Compatible IE=Edge
Even stranger, Chrome works great both in production mode and in development with a large dataset. But all other browsers don't work. Any help would be appreciated.
source to share
AFAIK from your post and Facebook ETag experience, you get "304 Not modified" because:
- You are sending the "HTTP_IF_NONE_MATCH" header from your request to the production server
- and your record has not been modified.
Your request only gets 200 responses if the backend doesn't match the etag value in Http-If-None-Match. If there is a match, you will receive "304 Not modified"
I think env production. included etag and followed up env, didn't.
You can take a look at this, http://archives.ryandaigle.com/articles/2008/8/14/what-s-new-in-edge-rails-simpler-conditional-get-support-etags
source to share