Forum Moderators: not2easy
<?php
ob_start ("ob_gzhandler");
header("Content-type: text/css");
header("Cache-Control: must-revalidate");
$offset = 60 * 60 ;
$ExpStr = "Expires: " .
gmdate("D, d M Y H:i:s",
time() + $offset) . " GMT";
header($ExpStr);
?>
...then added a line to my .htaccess file so .css files would be parsed for PHP.
The compression worked great, but unfortunately the W3C CSS Validator is now giving an error when I try to validate my stylesheet. The error is "Invalid content type," but I don't understand why the error is occurring since the content-type, as you can see above, is set to text/css.
Any ideas on what might be going on here? I thought at first the validator might not properly accept compressed content, but I'm sure I've validated CSS just fine when it was compressed with mod_gzip.
Thanks,
Matthew
1. In the includes directory I have added a .htaccess with the following:
AddHandler application/x-httpd-php .css 2. In the CSS file I have added your example code:
<?php
ob_start ("ob_gzhandler");
header("Content-Type: text/css");
header("Cache-Control: must-revalidate");
$offset = 60 * 60 ;
$ExpStr = "Expires: " .
gmdate("D, d M Y H:i:s",
time() + $offset) . " GMT";
header($ExpStr);
?> Are you using the separate file for the above code and using
auto_prepend_file or is the PHP inline? When I try the former method, the CSS is sent as text/html (and so is ignored by Firefox as the HTML is in standards-compliance mode), so there's a failure somewhere...
I wrote that article, and can report that I have never heard of anyone else having the problem that you are having. I'd love to help out, but I'm on holidays :D If you can't get this sorted send me a sticky mail and I'll see if I can help out; there are a few little tweaks some people used, but I can't recall what they were at the moment and they are on my other machine...
The compression itself works great, and I'm not getting any rendering errors. The only thing is that this is for a web design site, I want the HTML and CSS validate buttons at the bottom of the page, and if the CSS won't validate it looks pretty bad! ;)