Welcome Guest, Not a member yet? Register   Sign In
Looking for advice on a caching issue
#1

[eluser]kilishan[/eluser]
I've been adding caching to my Ocular Layout Library and have it 99% finished but have just a final stumbling block. I'm hoping someone that has worked on caching libs before might be able to help me get over this final hump.

What's happening is during the rendering of the page's layout I'm allowing it to be cached separately from the primary view itself. The caching part works correctly, but somewhere along the way I must be messing the output buffering layers, because the {elapsed_time} is not getting updated as it should be. Here's the main code that's causing the issue. If you would like to look at the full source, head over to the github page linked above, change to Tag 2.10 and give it a download.

Code:
//
        // Time to render the layout
        //
        
        // Save the cache settings for this primary view. This should
        // Override the default settings.
        $this->cache_view = is_null($cache_me) ? $this->cache_view : $cache_me;
        
        $this->cache_id = md5($layout . $this->ci->uri->uri_string);
        
        if ($this->cache_layout && $this->is_cached('layout'))
        {
            // Show the cache
            $output = $this->get_cache();
            echo str_replace('{yield}', $this->yield(true), $output);
        } else
        {    
            // Save our output buffer
            ob_start();
        
            // Start by checking if there's a theme available
            if (!empty($this->active_theme))
            {
                // A theme has been specified. First try to locate the file under
                // the active theme. If that doesn't work, fall back to the default theme.
                if ($this->ci->load->view($this->_check_layout($layout), $this->data) === FALSE)
                {
                    // Oops. Not found in active theme. Try the default.
                    if ($this->ci->load->view($this->_check_layout($layout, true), $this->data) === FALSE)
                    {
                        // Layout not found, so spit out an error.
                        show_error('Unable to load the requested file: ' . $layout);
                    }
                }
            } else
            {    
                // We're not using themes, so default to the 'views' folder
                if ($this->ci->load->view($layout, $this->data) === FALSE)
                {
                    // Show an error here, since we're overriding CI's loader.
                    show_error('Unable to load the requested file: '. $layout);
                }
            }
            
            // Cache the output buffer if required.
            if ($this->cache_layout && !$this->is_cached())
            {
                $output = ob_get_contents();
                ob_end_clean();
                $this->write_cache($output);
                echo str_replace('{yield}', $this->yield(true), $output);
            }
        }

Thanks in advance!




Theme © iAndrew 2016 - Forum software by © MyBB