0

I have two pages, a landing page and a profile page.

Here are the relevant parts of rake routes:

index GET /welcome/index(.:format)                   welcome#index
show GET /profile(/:username)(.:format)             sessions#show
root     /                                          welcome#index

When I got to localhost/, in my logs, I see a GET request for "/" followed by a GET request for "/profile." This is problematic because I launch an ajax request to the database if the page contains a div called "results," which "/profile" does. So while I don't see this request in my javascript console, I do see it on the web server console.

Similarly, if I go to /profile, I see a request for /profile, followed by a request for /. If I go to /welcome/index, I see a request for /, followed by a request for /welcome/index.

I am using omniauth to log into twitter in my app, but I don't think this is the cause - I can comment out the provider :twitter line in omniauth.rb, restart the web server and still see the problem.

I am stumped - I cannot tell where these requests are coming from. All I have been able to garner from the extra request object is that they are not AJAX requests.

Edit: I tested this in Safari, and this doesn't appear to happen there, so it is only happening on Chrome for me.

alexpelan
  • 35
  • 2
  • 11

1 Answers1

0

I figured this out, thanks to this related question

Chrome has a setting called "Predict network actions to improve page performance." Since I have done this action (arrive on page A, click to page B) so often while testing my app, Chrome just assumes I'm going to do that and prefetches it. I'll just have to write my code in such a way that we don't do extra writes to the database if this happens.

Community
  • 1
  • 1
alexpelan
  • 35
  • 2
  • 11