Forum Moderators: coopster

Message Too Old, No Replies

CSS and PHP file not working on IE

         

Psychopsia

4:46 pm on Oct 18, 2006 (gmt 0)

10+ Year Member



Hi!

I have a CSS problem with an under development website in PHP, CSS, Apache.

I created a rewrite rule in htaccess to a file to look like a CSS, but it's a dynamic PHP file, to send to browser the styles depending on browser.
The site works fine in Firefox, but IE don't, I think the problem is with my php code, because if I link to real css file works normal.

Specifically when moving between pages on IE, the first time the style shows ok, but if I click on a link the page loads but the style don't, and when press F5 on the same page everything works fine again.

I disabled the rewrite to see what's happening, and the site started to works again, without this problem.
So, maybe the problem is when PHP sends the dynamic CSS to the browser, here is part of the code:

$is_firefox = (strstr($this->browser, 'Gecko'))? true : false;
$is_ie = (strstr($this->browser, 'IE'))? true : false;

if (strstr($this->browser, 'compatible') ¦¦ $is_firefox)
{
ob_start('ob_gzhandler');
}

// Headers
header('Cache-Control: private, no-cache="set-cookie", pre-check=0, post-check=0');
header('Expires: 0');
header('Pragma: no-cache');
header('Content-type: text/css');

$style->assign_vars(array(
'FF' => $is_firefox,
'IE' => $is_ie)
);

$style->set_filenames(array('body' => 'css/default.css'));

$style->pparse('body');

What is the $style var? It uses a template system.
Why do use $this? Because this code is inside a method.

In Firefox everything works normal.

Can you help with this problem, please?

[edited by: Psychopsia at 4:47 pm (utc) on Oct. 18, 2006]

DanA

4:57 pm on Oct 18, 2006 (gmt 0)

10+ Year Member



Although it is not a good solution to use php/css, here is what I use :

header("Content-type: text/css; charset=iso-8859-1");
header("Cache-Control: must-revalidate");
$use_cache = 3600;//set to 0 if you want
$Expiration = "Expires: ".gmdate("D, d M Y H:i:s",time() + $use_cache)." GMT";
header($Expiration);

[edited by: DanA at 4:58 pm (utc) on Oct. 18, 2006]

Psychopsia

5:21 pm on Oct 18, 2006 (gmt 0)

10+ Year Member



Thank you for help DanA!

I added header Expires at the next line of the last header, and now the pages are loading normal in IE.

header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 60) . ' GMT');