在Rails Controller上使用相同的URL收到两次HTTP请求

时间:2014-01-15 03:22:42

标签: ruby-on-rails-3 http http-headers spree

我使用的是Rails 3.2.14和Spree 2-0-stable,但不知道它是否与Spree有关。用户点击进入商品定制页面的链接。据我了解,将获取获取产品的http请求以及其他资产请求。

这种情况正在发生,但我收到的另一个请求包含与开始时发起的主要请求相同的URL。这导致问题,因为路线通向相同的控制器并且整个处理重复两次。我使用实时http标头仔细查看标题,发现一些不寻常的东西。捕获这些字段:

主要请求(HTTP标头中的少数字段):

http://localhost:3000/products/birthday-candles?products%5Bproduct_id%5D=40&products%5Bvariant_id%5D=102&quantity=1    
GET /products/birthday-candles?products%5Bproduct_id%5D=40&products%5Bvariant_id%5D=102&quantity=1 HTTP/1.1    
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8    
Referer: http://localhost:3000/cards/showcase?taxon=Birthday+Products

第二个请求(很少摘自HTTP标头):

http://localhost:3000/products/birthday-candles?products%5Bproduct_id%5D=40&products%5Bvariant_id%5D=102&quantity=1#    
GET /products/birthday-candles?products%5Bproduct_id%5D=40&products%5Bvariant_id%5D=102&quantity=1 HTTP/1.1
Accept: image/png,image/*;q=0.8,*/*;q=0.5
Referer: http://localhost:3000/products/birthday-candles?products%5Bproduct_id%5D=40&products%5Bvariant_id%5D=102&quantity=1

可以在setupHttpLogs找到http标头日志的完整快照。

在第二次请求之后,我看到从提取的资产中获得了大约5-6个图像。

但是,第二个请求还包含与引用者相同的URL,因此我怀疑某些循环依赖但却无法确定其中一个。

在第二个请求中观察到循环引用表示什么?调试和解决它的可能方法是什么?

任何帮助/指示都将受到高度赞赏。

1 个答案:

答案 0 :(得分:0)

检查您的网络面板,看看您的javascript / css是否发送了错误的网址,然后检查您的第三方插件和JS / CSS是否有信标。

https://stackoverflow.com/a/5786750/94668