Gzip compressed css file with php header, first css line does not work
I am using gzip to compress my files so I need to add the following code to the top.
ob_start("ob_gzhandler");
header("content-type: text/css; charset: UTF-8");
header("cache-control: must-revalidate");
header("expires: ".gmdate('D, d M Y H:i:s',开发者_如何学JAVA time() + 1000)." GMT");
The problem is now that the first line of css code in my file does not work. e.g.
body{
color: red;
font-weight: bold;
}
using this the text would be bold but not red.
Looking forward to an advice.
Thanks in advance.
Edit:
From the comments, it turned out to be because:
the php code was inserting something into the css file.
Probably either:
- an unprintable character similar to this: CSS: Is there any difference between these two parts?
- or a UTF-8 BOM.
The font-color
property does not exist.
Use color: red
instead.
If the text is indeed bold, then your CSS file is working, so there shouldn't be any more problems.
Although I think the last line of your PHP should be:
header("expires: ".gmdate('D, d M Y H:i:s', time() + 1000)." GMT");
精彩评论