Chache problem running two consecutive HTTP GET requests from an APP1 to an APP2
- by user502052
I use Ruby on Rails 3 and I have 2 applications (APP1 and APP2) working on two subdomains:
app1.domain.local
app2.domain.local
and I am tryng to run two consecutive HTTP GET requests from APP1 to APP2 like this:
Code in APP1 (request):
response1 = Net::HTTP.get( URI.parse("http://app2.domain.local?test=first&id=1") )
response2 = Net::HTTP.get( URI.parse("http://app2.domain.local/test=second&id=1") )
Code in APP2 (response):
respond_to do |format|
if <model_name>.find(params[:id]).<field_name> == "first"
<model_name>.find(params[:id]).update_attribute ( <field_name>, <field_value> )
format.xml { render :xml => <model_name>.find(params[:id]).<field_name> }
elsif <model_name>.find(params[:id]).<field_name> == "second"
format.xml { render :xml => <model_name>.find(params[:id]).<field_name> }
end
end
After the first request I get the correct XML (response1 is what I expect), but on the second it isn't (response2 isn't what I expect). Doing some tests I found that the second time that <model_name>.find(params[:id]).<field_name> run (for the elsif statements) it returns always a blank value so that the code in the elseif statement is never run.
Is it possible that the problem is related on caching <model_name>.find(params[:id]).<field_name>?
P.S.: I read about eTag and Conditional GET, but I am not sure that I must use that approach. I would like to keep all simple.