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.

header("content-type: text/css; charset: UTF-8");
header("cache-control: must-revalidate");
header("expires: ".gmdate('D, d M Y H:i:s', time() + 1000)." GMT"); 

The problem is now that the first line of css code in my file does not work. e.g.

  color: red;
  font-weight: bold;

using this the text would be bold but not red.

Looking forward to an advice.

Thanks in advance.





From the comments, it turned out to be because:

the php code was inserting something into the css file.

Probably either:

Thefont-color property does not exist.

Use 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"); 

People are also looking for solutions to the problem: php json decode issue


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.