我有一个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)
开发和生产都会发生这种情况。它独立于浏览器
发生基于对其他SO线程和一般预感的建议,我尝试过:
'#'
并使用'javascript:void(0)'
而不是bundle exec rake assets:clobber
config.assets.prefix = '/dev-assets'
async: true
javascript_include_tag
bundle exec rake tmp:clear
这些似乎都不起作用。我现在都没有选择 - 有什么建议吗?
更新:结果是页面上嵌入了pinterest链接的罪魁祸首,当我删除它时,问题就消失了 - 这是导致它的来源 - 如何修复它以嵌入pinterest链接仍然没有多次调用?
我在页面中放入了一个用于嵌入式引脚的网址和脚本:
<a data-pin-do='embedPin' href='https://in.pinterest.com/pin/384143043191907516/'></a>
<script src="//assets.pinterest.com/js/pinit.js"></script>
注意:我在脚本中也有async defer,如下所示(这是pinterest网站建议嵌入pinterest链接的内容),但保留或删除它们对这两个请求问题没有任何区别:
<script async defer src="//assets.pinterest.com/js/pinit.js"></script>
运行脚本生成的页面源:
<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("http://media-cache-ak0.pinimg.com/237x/f0/75/0b/f0750bea877d546aa4a95f52a9007cc8.jpg");">
</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("http://media-cache-ec0.pinimg.com/favicons/09b6198f50d7e654ebb5f88e2016b83b0bb345386f0c4b685df4bacd.png?66c0426c45356a3c0afbd2cf5c32c99e");"></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("http://media-cache-ak0.pinimg.com/avatars/beblydia_1447515585_60.jpg");"></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>
答案 0 :(得分:1)
之前我遇到过类似的问题..它只发生在Chrome中,我通过添加
将其缩小到了turbolinks的问题data-no-turbolink
到我模板的body标签。这阻止了这个问题,特别是更新了turbolinks
bundle update turbolinks
好像整理了一切。我希望这有帮助!