Rails图像消失,出现错误:无法加载资源:net :: ERR_CONTENT_LENGTH_MISMATCH
基本上我的问题是页面加载正常并且看起来正常。 大约30秒后它突然消失了。
这是错误之前的服务器日志(加载页面时):
Started GET "/" for 127.0.0.1 at 2014-03-11 23:53:30 -0400 Processing by PagesController#home as HTML Rendered pages/home.html.erb within layouts/application (0.7ms) Rendered layouts/_head.erb (3.3ms) Rendered layouts/_header.erb (0.9ms) Rendered layouts/_footer.erb (0.2ms) Completed 200 OK in 11ms (Views: 10.5ms) Started GET "/assets/favicon.ico" for 127.0.0.1 at 2014-03-11 23:53:30 -0400 Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2014-03-11 23:53:30 -0400 Started GET "/assets/home.css?body=1" for 127.0.0.1 at 2014-03-11 23:53:30 -0400 Started GET "/assets/taylor.jpg" for 127.0.0.1 at 2014-03-11 23:53:30 -0400 Started GET "/assets/wide.jpg" for 127.0.0.1 at 2014-03-11 23:53:30 -0400 Started GET "/assets/enchanted_large.png" for 127.0.0.1 at 2014-03-11 23:53:30 -0400 Started GET "/assets/sad.jpg" for 127.0.0.1 at 2014-03-11 23:53:30 -0400
然后突然图像因客户端错误而消失(在Chrome的开发控制台中看到):
Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH http://localhost:3000/assets/taylor.jpg
而日志的唯一补充是:
Started GET "/assets/favicon.ico" for 127.0.0.1 at 2014-03-11 23:54:00 -0400
在看起来不错的30秒内,镀铬有一个装载符号,其中有图标
我的HTML在这一点上相当简单:
我甚至完全拿出了我的javascript。 我也试过自己去掉turbolinks。 它只发生在一个图像上。 我不明白为什么……
当我切换html时,它是同一个图像(泰勒)给出了错误:
我的所有图片都位于我的app / assets / images文件夹中
我的标题看起来像这样:
Enchanting Events and Design
当我使用mv
命令替换图像时,我遇到了这个问题。 这使得时间戳保持不变,因此打破了资产缓存。 只需touch
受影响的文件即可修复它。
当我编辑图像大小时遇到同样的问题。
上述解决方案都不适用于我,但是rake tmp:clear
就是这样!
尝试“rake assets:clean”并重建您的资产(如果需要)。 我通过这种魔法得到了工作。
这可能是nginx的另一个问题的症状。 请看这篇文章:
Rails图像消失,出现错误:无法加载资源:net :: ERR_CONTENT_LENGTH_MISMATCH
我看到了和你一样的问题,结果certificate是底层缓存目录的nginx权限问题,这也导致问题有点间歇性。