My page loads fine then as soon as you hit the refresh button all the styling disappears.
我的页面加载得很好,一旦你点击了刷新按钮,所有的样式都消失了。
It seems to be specific to chrome. If I look at the network tab I see that my css files returned with 304 Not modified but the type has changed to text/html. On initial load it is text/css.
它似乎是chrome特有的。如果我查看network选项卡,我看到我的css文件返回时没有修改304,但是类型已经更改为text/html。初始加载时是文本/css。
If I turn off caching everything works fine.
如果我关闭缓存,一切正常。
I saw a similar question on here but It was working before and I have not changed servers.
我在这里看到了一个类似的问题,但它以前是有效的,我没有更改服务器。
I seem to have narrowed it down to a problem with one css file. In particular adding a background image.
我似乎把它缩小到一个css文件的问题。特别是添加背景图像。
body {background:#b4dfff url(/images/backgrounds/background.jpg) no-repeat fixed top;
text-align:left;
font-family: Helvetica, Arial, sans-serif;
color: #585858;
font-size: 12px;
}
if I remove the background the problem occurs significantly less frequently. I tried changing it to
如果我删除背景,问题发生的频率就会大大降低。我试着把它改成
background-color:#b4dfff;
Background-image:url(/images/backgrounds/background.jpg) no-repeat fixed top;
that didn't work
没有工作
2 个解决方案
#1
2
It turns out this has to do with chrome handling the 304 response.
事实证明,这与chrome处理304响应有关。
Chrome asks for content and receives a 304 response saying it is not modified.
Chrome要求提供内容,并收到304个回复,说它没有修改。
When IIS returns a 304 response it has content-type in it. Chrome doesn't ignore the content type and looks and sees that the content type has been changed since IIS just returns the default type chrome thinks the file is no longer a stylesheet and doesn't load it.
当IIS返回304响应时,它在其中包含内容类型。Chrome并没有忽略内容类型,而是看到内容类型已经更改,因为IIS只返回默认类型,Chrome认为文件不再是样式表,也没有加载它。
So in order to fix this we made it reload stylesheets everytime. I have not figured out an easy way to modify the 304 response so that it does not include content-type.
为了解决这个问题,我们每次都要重新加载样式表。我还没有找到一种简单的方法来修改304响应,使它不包含内容类型。
Here is the google issue https://code.google.com/p/chromium/issues/detail?id=246875
下面是谷歌发布的https://code.google.com/p/chromium/issues/ issues/detail?id=246875
#2
1
same exact problem is mentioned here : http://productforums.google.com/forum/#!topic/chrome/zID6uQQfKH8 It seems like a temporary solution could be
这里也提到了相同的问题:http://productforums.google.com/forum/#!主题/chrome/zID6uQQfKH8似乎是一个临时的解决方案
turning off ETags and setting no-cache in HTTP header.
关闭ETags并在HTTP报头中设置无缓存。
#1
2
It turns out this has to do with chrome handling the 304 response.
事实证明,这与chrome处理304响应有关。
Chrome asks for content and receives a 304 response saying it is not modified.
Chrome要求提供内容,并收到304个回复,说它没有修改。
When IIS returns a 304 response it has content-type in it. Chrome doesn't ignore the content type and looks and sees that the content type has been changed since IIS just returns the default type chrome thinks the file is no longer a stylesheet and doesn't load it.
当IIS返回304响应时,它在其中包含内容类型。Chrome并没有忽略内容类型,而是看到内容类型已经更改,因为IIS只返回默认类型,Chrome认为文件不再是样式表,也没有加载它。
So in order to fix this we made it reload stylesheets everytime. I have not figured out an easy way to modify the 304 response so that it does not include content-type.
为了解决这个问题,我们每次都要重新加载样式表。我还没有找到一种简单的方法来修改304响应,使它不包含内容类型。
Here is the google issue https://code.google.com/p/chromium/issues/detail?id=246875
下面是谷歌发布的https://code.google.com/p/chromium/issues/ issues/detail?id=246875
#2
1
same exact problem is mentioned here : http://productforums.google.com/forum/#!topic/chrome/zID6uQQfKH8 It seems like a temporary solution could be
这里也提到了相同的问题:http://productforums.google.com/forum/#!主题/chrome/zID6uQQfKH8似乎是一个临时的解决方案
turning off ETags and setting no-cache in HTTP header.
关闭ETags并在HTTP报头中设置无缓存。