Welcome Guest, Not a member yet? Register   Sign In
Cache / caching - is it working?
#1

[eluser]Bullit2k[/eluser]
Hi All,
I was suffering with a mysql database that was having to handle too many queries.
To cut down the need to get data from the database so often,
I put $this->output->cache(420); //to cache full pages for 7hrs at a time.

This code is in my main controller right at the top.
system/cache is writeable and filling nicely with cached pages. Inspection of a b603b82kfsjlfkjel file shows it is indeed a cached page.

However, I'm not seeing the effects of this cache.
if I edit a page's content with my custom CMS I'd expect to have to clear this cache to see the change. However I see the change immediately.

Also the database still looks to be handling the same number of queries.
(I know the majority of these queries relate to page data.)

Any ideas what to do next? Or is cache on and it's not that good?
The fact I can see changes on dynamic pages straight away makes me think it's not looking at the cache.
Is there another piece to this puzzle?

Any advice welcome.
Thanks
#2

[eluser]brianw1975[/eluser]
didn't see it noted, but make sure you have the proper write permissions on the cache folder

Quote:Note: Before the cache files can be written you must set the file permissions on your system/cache folder such that it is writable.
#3

[eluser]Bullit2k[/eluser]
Hi, cache folder is writable. It's filling with content nicely. (complete pages)

how do I confirm that my site is reading the cached content??
#4

[eluser]Kip zonder Kop[/eluser]
Maybe you could enable the profiler (http://ellislab.com/codeigniter/user-gui...iling.html) to see what is happening.
#5

[eluser]Bullit2k[/eluser]
Hi, cheers for the profiler - shows me all the sql being run etc for the page.
Useful.

however, I'd expect no sql output to be displayed if the page was successfully coming from cache. Shouldn't this be the case?

Or is cache ignored when the profiler is turned on? (catch 22!)
#6

[eluser]Kip zonder Kop[/eluser]
[quote author="Bullit2k" date="1259341797"]Or is cache ignored when the profiler is turned on? (catch 22!)[/quote]

No, that is not the case. You should see nothing when caching works. Are you sure your caching statement is being executed. Where did you put it. I would put it in your class constuctor, then you can be sure it will be executed.
#7

[eluser]Bullit2k[/eluser]
I'm sure it's being executed - as cache folder is filling up with pages.

Code is placed in my main controller:
Code:
<?

class Pages extends Controller {

    function Pages()
    {
        parent::Controller();    
        
        $this->output->cache(420);

You've seen the profiler with caching on and seen that no sql is called?

I just need to figure why my cache isn't being pulled back out by CI
#8

[eluser]Bullit2k[/eluser]
Ok, from output.php in ci system libraries:

Code:
// Does the get_instance() function exist?
        // If not we know we are dealing with a cache file so we'll
        // simply echo out the data and exit.
        if ( ! function_exists('get_instance'))
        {
                     //problem for me here --- not entering this
                     //get_instance doesnt exist
                     //what's that? and how to make it exist?
            echo $output;
            log_message('debug', "Final output sent to browser");
            log_message('debug', "Total execution time: ".$elapsed);
            return TRUE;
        }

see my comments in above code...
#9

[eluser]Kip zonder Kop[/eluser]
[quote author="Bullit2k" date="1259344340"]
see my comments in above code...[/quote]

I am not sure I understand you. In my view you end up in the body of the if statement if caching is working properly. But you say caching is not working.
#10

[eluser]Bullit2k[/eluser]
Caching is on: $this->output->cache(420);
Cache folder is filling up.

But profiler is showing mysql queries and the output isn't going into the body of the if statement above.

So, it's not outputting from my cached files...

(thanks for help so far btw)




Theme © iAndrew 2016 - Forum software by © MyBB