简体   繁体   English

Rails正在进行两次相同的get请求(更新:仅当我在页面上嵌入pinterest链接时)

[英]Rails is making the same get request twice (update: only when I embed pinterest links on the page)

I have a rails 4.2.x app, wherein I notice that for each request I make, the logs show that the whole request is being sent twice - One request gets fully completed, the page seems fully rendered, but then another one starts again in the logs and runs through its course, and the second request has no visible effect in the client browser. 我有一个rails 4.2.x应用程序,其中我注意到对于我做的每个请求,日志显示整个请求被发送两次 - 一个请求完全完成,页面似乎完全呈现,但然后另一个请求再次启动日志并在其过程中运行,第二个请求在客户端浏览器中没有可见效果。

Started GET "/path/to/request" for 10.0.1.5 at 2016-04-12 21:23:08 +0530
<... bunch of SQL and other logs to fulfill this request...>
Completed 200 OK in 11487ms (Views: 11279.3ms | ActiveRecord: 40.3ms)

Started GET "/path/to/request" for 10.0.1.5 at 2016-04-12 21:23:21 +0530
<... same bunch of SQL and other logs ...>
Completed 200 OK in 8928ms (Views: 8899.3ms | ActiveRecord: 18.2ms)

This happens both on dev and production. 开发和生产都会发生这种情况。 It happens independent of browser 它独立于浏览器而发生

Based on suggestions on other SO threads and general hunches, I have tried: 基于对其他SO线程和一般预感的建议,我尝试过:

  1. Removing all links that point to '#' and using 删除指向'#'并使用的所有链接
    'javascript:void(0)' instead 'javascript:void(0)'而不是
  2. Calling bundle exec rake assets:clobber 调用bundle exec rake assets:clobber
  3. In development.rb, set config.assets.prefix = '/dev-assets' 在development.rb中,设置config.assets.prefix = '/dev-assets'
  4. Removing async: true from javascript_include_tag javascript_include_tag删除async: true
  5. Tried calling from chrome incognito window 尝试从Chrome隐身窗口调用
  6. Restarting browser 重新启动浏览器
  7. Clearing the tmp folder with bundle exec rake tmp:clear 使用bundle exec rake tmp:clear清除tmp文件夹bundle exec rake tmp:clear
  8. Restarting the (dev) machine 重启(dev)机器
  9. I do not have turbolinks in my Gemfile or Gemfile.lock 我的Gemfile或Gemfile.lock中没有turbolinks

None of these seem to work. 这些似乎都不起作用。 I am all out of options right now - any suggestions? 我现在都没有选择 - 任何建议?

Update : turns out the culprit was embedded pinterest links on the page, when I remove it, the issue goes away - here is the source that caused it - how do I fix it to embed pinterest links and still not have multiple calls occur? 更新 :结果是罪魁祸首是页面上嵌入的pinterest链接,当我删除它时,问题消失了 - 这是导致它的来源 - 我如何修复它嵌入pinterest链接仍然没有多次调用发生?

The url and script I put in the page for an embedded pin: 我在页面中放置了一个用于嵌入式引脚的URL和脚本:

<a data-pin-do='embedPin' href='https://in.pinterest.com/pin/384143043191907516/'></a>

<script src="//assets.pinterest.com/js/pinit.js"></script>

Note: I also had async defer in the script as shown below (that is what the pinterest site recommends for embedding pinterest links), but keeping or removing them made no difference to the two request issue: 注意:我在脚本中也有async defer,如下所示(这是pinterest网站建议嵌入pinterest链接的内容),但保留或删除它们对两个请求问题没有区别:

<script async defer src="//assets.pinterest.com/js/pinit.js"></script>

The page source that was generated by the script running: 运行脚本生成的页面源:

<span class="PIN_1460479728283_embed_pin PIN_1460479728283_en" data-pin-log="embed_pin" data-pin-href="https://www.pinterest.com/pin/384143043191907516/" data-pin-id="384143043191907516"><span class="PIN_1460479728283_bd" data-pin-href="https://www.pinterest.com/pin/384143043191907516/" data-pin-log="embed_pin">
<span class="PIN_1460479728283_hd" data-pin-href="https://www.pinterest.com/pin/384143043191907516/" data-pin-log="embed_pin">     
<span class="PIN_1460479728283_container" data-pin-href="https://www.pinterest.com/pin/384143043191907516/" data-pin-log="embed_pin" style="padding-bottom: 154.43%;"><span class="PIN_1460479728283_img" data-pin-href="https://www.pinterest.com/pin/384143043191907516/" data-pin-log="embed_pin_img" data-pin-src="http://media-cache-ak0.pinimg.com/237x/f0/75/0b/f0750bea877d546aa4a95f52a9007cc8.jpg" style="background-image: url(&quot;http://media-cache-ak0.pinimg.com/237x/f0/75/0b/f0750bea877d546aa4a95f52a9007cc8.jpg&quot;);">
</span></span>
<span class="PIN_1460479728283_repin" data-pin-href="https://www.pinterest.com/pin/384143043191907516/" data-pin-log="embed_pin_repin" data-pin-id="384143043191907516"></span></span><span class="PIN_1460479728283_source" data-pin-href="http://guineapiggies.tumblr.com/post/62520038756/perlita-by-gabitayuz" data-pin-log="embed_pin_domain"><span class="PIN_1460479728283_img" data-pin-href="http://guineapiggies.tumblr.com/post/62520038756/perlita-by-gabitayuz" data-pin-log="embed_pin_domain" data-pin-src="http://media-cache-ec0.pinimg.com/favicons/09b6198f50d7e654ebb5f88e2016b83b0bb345386f0c4b685df4bacd.png?66c0426c45356a3c0afbd2cf5c32c99e" style="background-image: url(&quot;http://media-cache-ec0.pinimg.com/favicons/09b6198f50d7e654ebb5f88e2016b83b0bb345386f0c4b685df4bacd.png?66c0426c45356a3c0afbd2cf5c32c99e&quot;);"></span><span class="PIN_1460479728283_domain" data-pin-href="http://guineapiggies.tumblr.com/post/62520038756/perlita-by-gabitayuz" data-pin-log="embed_pin_domain">Guinea Piggies
</span>
<span class="PIN_1460479728283_menu" data-pin-href="http://guineapiggies.tumblr.com/post/62520038756/perlita-by-gabitayuz" data-pin-log="embed_pin_domain"><span class="PIN_1460479728283_toggle" data-pin-href="" data-pin-log="embed_pin_toggle"></span><span class="PIN_1460479728283_dropdown" data-pin-href="https://www.pinterest.com/about/copyright/dmca-pin/?id=384143043191907516" data-pin-log="embed_pin_report">Copyright issue
</span>
</span>
</span><span class="PIN_1460479728283_description" data-pin-href="https://www.pinterest.com/pin/384143043191907516/" data-pin-log="embed_pin">guinea pig</span><span class="PIN_1460479728283_stats" data-pin-href="https://www.pinterest.com/pin/384143043191907516/" data-pin-log="embed_pin"><span class="PIN_1460479728283_repins" data-pin-href="https://www.pinterest.com/pin/384143043191907516/repins/" data-pin-log="embed_pin">1</span></span></span><span class="PIN_1460479728283_ft" data-pin-href="https://www.pinterest.com/beblydia/" data-pin-log="embed_pin_pinner"><span class="PIN_1460479728283_img" data-pin-href="https://www.pinterest.com/beblydia/" data-pin-log="embed_pin_pinner" data-pin-src="http://media-cache-ak0.pinimg.com/avatars/beblydia_1447515585_60.jpg" style="background-image: url(&quot;http://media-cache-ak0.pinimg.com/avatars/beblydia_1447515585_60.jpg&quot;);"></span><span class="PIN_1460479728283_pinner" data-pin-href="https://www.pinterest.com/beblydia/" data-pin-log="embed_pin_pinner">Lydia Batista</span><span class="PIN_1460479728283_board" data-pin-href="https://www.pinterest.com/beblydia/guinea-pigs/" data-pin-log="embed_pin_board">Guinea pigs
</span></span></span>

I had a similar issue before.. it was only happening in Chrome and I narrowed it down to there being an issue with turbolinks by adding 之前我遇到过类似的问题..它只发生在Chrome中,我将其缩小到通过添加turbolinks来解决问题

data-no-turbolink

to the body tag of my template. 到我的模板的body标签。 This stopped the issue, and specifically updating turbolinks 这阻止了这个问题,特别是更新了turbolinks

bundle update turbolinks

seemed to sort it all out. 似乎全力以赴。 I hope this helps! 我希望这有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我单击Rails中的侧边栏链接时如何保持在同一页面上 - How to stay on the same page when I click on sidebar links in Rails 在Rails中,如何在不发出HTTP请求的情况下获取页面的内容? - In Rails how can I get the contents of a page without making an HTTP request? 在Rails中使用AJAX进行DELETE请求时,如何从表单中获得不同的ID值? - How do I get different id values from a form when making a DELETE request using AJAX in Rails? Rails 4:coffeescript仅在有帖子请求或重新加载页面时才有效 - Rails 4: coffeescript only works when there is a post request or when i reload the page Rails 4:是否可以将Ajax .get请求发送到同一个当前页面控制器? - Rails 4: is it possible send Ajax .get request to same current page controller? Rails - 使页面只能被管理员查看 - Rails - Making a page viewable to admin only 发出API请求时在Rails中进行插补 - Interpolation in rails when making an API request rails / rspec向主体发出对API的发布请求时如何获取响应? - rails/rspec how to get the response when making a post request with body to API? 提交到同一页面时如何添加到Rails会话中? - How do I add to a rails session when submitting to same page? jQuery仅在刷新页面以切换Rails应用程序时有效 - jquery only works when I refresh the page for toggle for rails app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM