Rails图像消失并显示错误:无法加载资源:net :: ERR_CONTENT_LENGTH_MISMATCH [英] Rails image disappears with error: Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH
问题描述
本质上,我的问题是页面加载正常且看起来正常.大约30秒后,它突然消失了.
Essentially my problem is that a page loads fine and looks normal. After about 30 seconds it suddenly disappears.
以下是错误之前的服务器日志(加载页面时):
Here's the server log before the error (as loading the page):
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的开发控制台中可见):
And then suddenly the image dissappears with the client side error (seen in Chrome's dev console):
Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH
http://localhost:3000/assets/taylor.jpg
日志中唯一的附加内容是:
And the only addition to the log is:
Started GET "/assets/favicon.ico" for 127.0.0.1 at 2014-03-11 23:54:00 -0400
在看起来不错的30秒内,Chrome在收藏图标的位置出现了加载符号
During the 30 seconds of it looking good, chrome has a loading symbol where the favicon goes
此时,我的html很简单:
My html is rather simple at this point:
<div class="home-images">
<%= image_tag "taylor.jpg", class: "home-image" %>
<%= image_tag "wide.jpg", class: "home-image hide" %>
<%= image_tag "sad.jpg", class: "home-image hide" %>
</div>
我什至完全掏出了我的JavaScript.我也尝试过自己删除turbolinks.它仅发生在一张图像上.而且我不知道为什么...
I even took out my javascript completely. I tried removing turbolinks by itself too. It only happens to one image. And I have no idea why...
当我切换html时,出现错误的是同一张图片(泰勒):
When I switched the html, it was the same image (taylor) that gave the error:
<div class="home-images">
<%= image_tag "wide.jpg", class: "home-image" %>
<%= image_tag "taylor.jpg", class: "home-image hide" %>
<%= image_tag "sad.jpg", class: "home-image hide" %>
</div>
我所有的图像都位于我的app/assets/images文件夹中
All my images are located in my app/assets/images folder
我的标题如下:
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Enchanting Events and Design</title>
<%= favicon_link_tag "favicon.ico" %>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
推荐答案
当我使用mv
命令替换图像时,出现了这个问题.这使时间戳保持不变,因此破坏了资产缓存.受影响的文件的简单touch
对其进行了修复.
I had this issue when I replaced an image using the mv
command. This left the timestamp untouched, so it broke the asset caching. A simple touch
of the affected file fixed it.
这篇关于Rails图像消失并显示错误:无法加载资源:net :: ERR_CONTENT_LENGTH_MISMATCH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!