Welcome Guest, Not a member yet? Register   Sign In
Specifying no sessions
#1

[eluser]a.somervell[/eluser]
Heya, we're in the "really small tweaks" part of our site relaunch and we've managed to get a YSlow 98/100 (Google Analytics is killing that elusive 99 and there's no such thing as 100) WOOP WOOP!

Our CSS and JS is served off the application server so we can parse things like site_url() in them. GZipping, setting far future expires headers, all that fun stuff...

I'd like to have the session class in autoload so I dont have to specify it *#$ing everywhere but its being called every time we serve static content. That means the ci_sessions table being updated every time someone comes in for CSS and JS and cookie information being sent with them. We'd like to get rid of that without pushing the CSS and JS to our static content server.

Can anyone think of a way to tell CI to ignore the session class on this particular controller? My first thought is that we have a "Utilities" library that's also auto-loaded, I could write something tricky in there to load the session class unless otherwise specified.
#2

[eluser]Pascal Kriete[/eluser]
I ran into this on an old project - in my case it was an installer that couldn't autoload the session, because the database config values weren't known yet.

What I ended up doing is overriding the core's _ci_initialize method to kill all autoloading code for that controller.
Code:
class Install extends Controller {

    /**
     * Constructor
     *
     * @access    private
     */
    function Install()
    {
        parent::Controller();
    }
    
    // --------------------------------------------------------------------

    /**
     * Index Function
     *
     * @access    public
     */
    function index()
    {
        // Code here
    }
    
    // --------------------------------------------------------------------

    /**
     * Overriden _ci_initialize function to skip the autoloading process
     *
     * @access    private
     */
    function _ci_initialize()
    {
        // Assign all the class objects that were instantiated by the
        // front controller to local class variables so that CI can be
        // run as one big super object.
        $classes = array(
                            'config'    => 'Config',
                            'input'        => 'Input',
                            'benchmark'    => 'Benchmark',
                            'uri'        => 'URI',
                            'output'    => 'Output',
                            'lang'        => 'Language',
                            'router'    => 'Router'
                            );
        
        foreach ($classes as $var => $class)
        {
            $this->$var =& load_class($class);
        }

        // In PHP 5 the Loader class is run as a discreet
        // class.  In PHP 4 it extends the Controller
        if (floor(phpversion()) >= 5)
        {
            $this->load =& load_class('Loader');
        }
        else
        {
            // sync up the objects since PHP4 was working from a copy
            foreach (array_keys(get_object_vars($this)) as $attribute)
            {
                if (is_object($this->$attribute))
                {
                    $this->load->$attribute =& $this->$attribute;
                }
            }
        }
    }
}




Theme © iAndrew 2016 - Forum software by © MyBB