• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
output's cache and performance

#1
[eluser]Bad Penguin[/eluser]
I am trying to use $this->output->cache(600) to reduce loading time of my pages.

Is there a way to check if the served page has been generated from the cache or its a full live php codeigniter page?
I'm getting always 2.200 seconds as loading time.
The same version of the page as static HTML takes 0.043 seconds.

I wonder what is taking so much time:
- apache+php itself
- $this->output->cache(600); placeced in wrong position (i have it in MY_Controller.php)
- something else

Any suggestions?

#2
[eluser]toopay[/eluser]
In real world/life performance, there are three core elements you should concern : Time To First Byte (which generally represent your server hardware/resources), good designed database and efficient caching schema(text and image compression, static resource cache and so on).

#3
[eluser]tomcode[/eluser]
0. Make sure Your cache path is correct (application/config.php) and the cache folder is writable

1. It does not matter were You call $this->output->cache(600), as long as it get's executed Wink

2. to check what's going on, set the log threshold to 2 in application/config.php

For the fist run Your log should show You
Code:
..
DEBUG - 2011-07-28 05:28:27 --> Cache file written: application/cache/5e707dc050024f67a67f3b0110243721
DEBUG - 2011-07-28 05:28:27 --> Final output sent to browser
DEBUG - 2011-07-28 05:28:27 --> Total execution time: 0.0572

For the second and subsequent runs You should see
Code:
..
DEBUG - 2011-07-28 05:28:42 --> Final output sent to browser
DEBUG - 2011-07-28 05:28:42 --> Total execution time: 0.0295
DEBUG - 2011-07-28 05:28:42 --> Cache file is current. Sending it to browser.

#4
[eluser]toopay[/eluser]
@tomcode, just wondering why you give an obvious knowledge of how to turn on the CI Log, while he asking about (or at least his concern is) app performance?
[quote author="Bad Penguin" date="1311774216"]I am trying to use $this->output->cache(600) to reduce loading time of my pages.
...
I wonder what is taking so much time:
- apache+php itself
- $this->output->cache(600); placeced in wrong position (i have it in MY_Controller.php)
- something else

Any suggestions?[/quote]

#5
[eluser]tomcode[/eluser]
@toopay
maybe I did not understand the question, but to me he is asking :

Quote:Is there a way to check if the served page has been generated from the cache or its a full live php codeigniter page?

This I can see by consulting the log as I have described, no ?

Wondering what takes so much time is to me a second step, after I have checked wether the cache is working.

I find it hard to evaluate the background (what is obvious) of the person posting, so I describe all steps ...

#6
[eluser]Mirge[/eluser]
[quote author="tomcode" date="1311852322"]@toopay
maybe I did not understand the question, but to me he is asking :

Quote:Is there a way to check if the served page has been generated from the cache or its a full live php codeigniter page?

This I can see by consulting the log as I have described, no ?

Wondering what takes so much time is to me a second step, after I have checked wether the cache is working.

I find it hard to evaluate the background (what is obvious) of the person posting, so I describe all steps ...[/quote]

That's what I read & thought as well. toopay jumped the gun, IMO Smile

To the OP: were you able to figure out if caching is working?

#7
[eluser]Bad Penguin[/eluser]
Thank for your time to providing me such long answer.

[quote author="tomcode" date="1311842367"]
1. It does not matter were You call $this->output->cache(600), as long as it get's executed Wink
[/quote]

Ok, tought i had to put that libraries call before anything else.

[quote author="tomcode" date="1311842367"]
2. to check what's going on, set the log threshold to 2 in application/config.php
DEBUG - 2011-07-28 05:28:27 --> Total execution time: 0.0572
[/quote]

Ok its working now, is 0.0206 acceptable PHP side or i should use a different cache driver like APC/Memcache instead of file?

Client side the page i 9KB and takes 125-250ms to fully download.

Before:
Code:
DEBUG - 2011-07-28 14:16:39 --> Cache file written: app/cache/83f9965d673372c75a2cd29befb94aef
DEBUG - 2011-07-28 14:16:39 --> Final output sent to browser
DEBUG - 2011-07-28 14:16:39 --> Total execution time: 2.3151

After:
Code:
DEBUG - 2011-07-28 14:19:29 --> Final output sent to browser
DEBUG - 2011-07-28 14:19:29 --> Total execution time: 0.0206
DEBUG - 2011-07-28 14:19:29 --> Cache file is current. Sending it to browser.

#8
[eluser]Bad Penguin[/eluser]
[quote author="toopay" date="1311844063"]@tomcode, just wondering why you give an obvious knowledge of how to turn on the CI Log, while he asking about (or at least his concern is) app performance?
[quote author="Bad Penguin" date="1311774216"]I am trying to use $this->output->cache(600) to reduce loading time of my pages.
...
I wonder what is taking so much time:
- apache+php itself
- $this->output->cache(600); placeced in wrong position (i have it in MY_Controller.php)
- something else

Any suggestions?[/quote][/quote]

In the end he was right, i've MY_Output class that will bypass cache if the client IP is from our development office. I'll check tonight from home again Smile


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.