[eluser]bertd[/eluser]
Hi,
I was wondering if anybody here could help me out with a little question I have.
I have a CSS file that is loaded through a controller & view. Please consider this example:
Code:
class Css extends Controller {
function Css()
{
parent::Controller();
$this->load->library('cssmin');
$cssmin_options = array(
'preserveComments'=>true,
'relativePath'=>$this->config->item('base_url').'resources/images/'
);
$this->cssmin->config($cssmin_options);
}
function main
{
header("Content-type: text/css");
$this->output->cache(15);
$this->data['css'] = $this->cssmin->minify(file_get_contents('./resources/stylesheets/main.css'));
$this->load->view('css/css', $this->data);
}
}
As you can see, I minify my CSS file with a custom library to save bandwidth. This is off course a very CPU intensive process so after the visitor has requested the CSS file, there really is no need to minify the file for every HTTP request the browser of the user makes. That is why I use
Code:
$this->output->cache(15);
to cache the file for at least 15 minutes.
This works perfect for the first request the users' browser makes. The second time, the CSS files seem to have the Content-type text/html, so no styling is applied
at all!
How can I use caching and make sure the Content-Type header is also cached, so codeigniter does not fall back to text/html but uses text/css??
Thanks!
Gr,
Bert