linux - cdn上css文件引入页面后,response为空
PHP中文网
PHP中文网 2017-04-17 15:01:59
0
2
558

网站中,为了提高访问速度,吧css,js都换成cdn,是很常见的需求,最近发现引入的部分css没有对页面进行渲染,查看原因是css文件已经成功加载,但是,response内容是空的,直接打开浏览器访问这个css是可以访问到内容的。

所以导致页面样式错乱:

这些文件都是在同一个cdn上的

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
Peter_Zhu

The reason has been found:

When the link in HTML introduces CSS, the file type is text/css. If the file type returned by the server does not match, then the response will be empty and cannot be loaded into the page.

This problem arises because CDN sets the file type to text/plain by default. Just change it to text/css

洪涛

The status codes of these files are all 304. These files are taken from the browser’s cache.

Forcibly clear the cache and test it multiple times, and then look at the results.

Also, how do you synchronize files to CDN?
Are you sure the files on the CDN are not empty? If so, I think it's due to your browser's cache.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template