tech stuff and scratch pad
Friday, March 18. 2011
Call to undefined function Xmlelement::header() cakephp
Thursday, January 13. 2011
boosting CakePHP speed with caching on production (xcache battery)
I have managed to speedup my production cakephp site that was taking 5+ seconds to load (sometimes 9 seconds). My purpose was to do something simple enough and little enough to get the most impact. Something I could use sitewide without coding. I do code optimization and code based caching at the end of lifecycle.
I already had debug set to 0. all my queries and functions are optimized.
so first I installed Xcache. cakephp suggested that there is some settings to be done in core.php for xcache but it was not required. because doing this has no effect for me. (I am not specifically caching any variables etc or views using code though its possible to do so). Just having xcache installed and setup correctly in php.ini for your the site is good enough. If you enable your xcache admin (i installed under webroot/xcache but you can install xcache admin anywhere and change your .htaccess files accordingly). You dont need to install xcache admin for caching to work but good to have so you know if its working and whats going on behind teh scenes.
after installing xcache i was able to bring down the load time for php page. (when testing ignore css/js etc) I use tools.pingdom.com where you can actually see what component is taking how much time so I ignore connect time and also assets. After implementing Xcache load time was down from from 5-9 seconds to 2-3 seconds load time. (php execution time was down from 3.7 to 1.1)
After this I edited my core.php for the cakephp site and enabled file caching engine site wide. that brought down the page load time to 0.9 to 1.1 second. This is good enough for me. I am able to load the entire page ove rthe network in 1.4 seconds now as opposed to 9 seconds before. I highly recommend doing this for production cakephp even if you don't enable any other caching engine. all you need to do is make sure the
cake's tmp/ directory is writable by web server and do the following in core.php
uncomment and change the following config in core.php for easy, no coding needed, sitewide , caching.
unless you are specifically caching actions and views using cakes internal methods (for which you must have written code in controller and views) you can leave the following setting disabled. Leave it commented.
So I have two levels of caching one is opcode caching and the file caching which is quite well known.
other stuff
I tried eaccelerator too, its not much difference from xcache, quite teh same. In case of cakephp, however in some cases eaccelerator was actually slower that having no opcode caching. I dont know why.
i dont use gzip as i dont have enough cpu to do so but I have ample bandwidth so I dont really care.
I use google app engine for delivering css and js. In production I avoid using to many cakephp calls for linking javascript and css files that are common, just used standard html code. I load from Google cloud and configure the GAE settings to expire the files in 4 days.
I already had debug set to 0. all my queries and functions are optimized.
so first I installed Xcache. cakephp suggested that there is some settings to be done in core.php for xcache but it was not required. because doing this has no effect for me. (I am not specifically caching any variables etc or views using code though its possible to do so). Just having xcache installed and setup correctly in php.ini for your the site is good enough. If you enable your xcache admin (i installed under webroot/xcache but you can install xcache admin anywhere and change your .htaccess files accordingly). You dont need to install xcache admin for caching to work but good to have so you know if its working and whats going on behind teh scenes.
after installing xcache i was able to bring down the load time for php page. (when testing ignore css/js etc) I use tools.pingdom.com where you can actually see what component is taking how much time so I ignore connect time and also assets. After implementing Xcache load time was down from from 5-9 seconds to 2-3 seconds load time. (php execution time was down from 3.7 to 1.1)
After this I edited my core.php for the cakephp site and enabled file caching engine site wide. that brought down the page load time to 0.9 to 1.1 second. This is good enough for me. I am able to load the entire page ove rthe network in 1.4 seconds now as opposed to 9 seconds before. I highly recommend doing this for production cakephp even if you don't enable any other caching engine. all you need to do is make sure the
cake's tmp/ directory is writable by web server and do the following in core.php
uncomment and change the following config in core.php for easy, no coding needed, sitewide , caching.
PHP:
<?php
Configure::write('Cache.disable', false);
// and this one just uncomment or copy paste at the end of the script.
Cache::config('default', array(
'engine' => 'File', //[required]
'duration'=> 3600, //[optional]
'probability'=> 100, //[optional]
'path' => CACHE, //[optional] use system tmp directory - remember to use absolute path
'prefix' => 'cake_', //[optional] prefix every cache file with this string
'lock' => false, //[optional] use file locking
'serialize' => true, //[optional]
));
?>
unless you are specifically caching actions and views using cakes internal methods (for which you must have written code in controller and views) you can leave the following setting disabled. Leave it commented.
PHP:
<?php
// Configure::write('Cache.check', true);
?>
So I have two levels of caching one is opcode caching and the file caching which is quite well known.
other stuff
I tried eaccelerator too, its not much difference from xcache, quite teh same. In case of cakephp, however in some cases eaccelerator was actually slower that having no opcode caching. I dont know why.
i dont use gzip as i dont have enough cpu to do so but I have ample bandwidth so I dont really care.
I use google app engine for delivering css and js. In production I avoid using to many cakephp calls for linking javascript and css files that are common, just used standard html code. I load from Google cloud and configure the GAE settings to expire the files in 4 days.
Sunday, July 4. 2010
How to make functions and links without views
Many times we just want to execute a bunch of server side code by clicking a link but not have views or anything else.
For e.g. I want to make a link for my visitors to clear their preferences stored in cookies.
We first write a function in controller just as we would for any other case. e.g.
The a simple link can be created anywhere in the views using
thats all.
For e.g. I want to make a link for my visitors to clear their preferences stored in cookies.
We first write a function in controller just as we would for any other case. e.g.
PHP:
<?php
//
// Function to reset the cookie and return to homepage
//
function reset(){
// Set the View file to nothing
$this->view = '';
// do whatever calls you need to do below. here i delete cookie
$this->Cookie->delete('preferences');
//finally send the visitor back to wherever, there is no view file for this case.
$this->redirect('/');
}
?>
The a simple link can be created anywhere in the views using
PHP:
<?php
echo $html->link('reset preferences',array('controller' => 'myconroller', 'action' => 'reset');
?>
thats all.
(Page 1 of 1, totaling 3 entries)
Search
The book that helped me most in my first Django production project
Calendar
|
|
February '12 | |||||
| Mon | Tue | Wed | Thu | Fri | Sat | Sun |
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | ||||
Categories
Syndicate This Blog
Last Search (Google, Yahoo, Bing, Scroogle)
Top Referrers
www.google.com (213)
www.cosmosonline.ru (183)
www.ayzek.ru (129)
www.preconception.ru (89)
www.iris-gardini.com.ua (87)
www.rakdoctor.ru (86)
www.filmmp3.ru (84)
cheat-online.ru (82)
www.graem.ru (82)
www.mixadance.info (80)
www.cosmosonline.ru (183)
www.ayzek.ru (129)
www.preconception.ru (89)
www.iris-gardini.com.ua (87)
www.rakdoctor.ru (86)
www.filmmp3.ru (84)
cheat-online.ru (82)
www.graem.ru (82)
www.mixadance.info (80)
© Copyright 2006, nerdwg.org design by Luka Cvrk, port for s9y by nerdwg.org
