Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter Caching Problem with HTTP Headers (Content-Type)


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:

class Css extends Controller {
    function Css()

        $cssmin_options = array(

    function main
        header("Content-type: text/css");

        $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
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??



Messages In This Thread
CodeIgniter Caching Problem with HTTP Headers (Content-Type) - by El Forum - 08-31-2010, 09:08 AM

Theme © iAndrew 2016 - Forum software by © MyBB