ArtioSEF performance hack |
| Friday, 15 June 2007 | ||||
|
NOTE: Artio JoomSef versions 2.0.0, 3.0 or later have their own caching mechanism, you don't need to apply this patch! Yes, I'm obsessed with caching. There are reasonable reasons to use it, too. I got banned by my shared hosting provider for eating up 100% CPU with sql queries. Why did this happen? Because ArtioSEF is performing a query for every URL on you Joomla site each time you load a page. All the menus, pagination links, forum links, category views, call sefRelToAbs to translate a regular URL into a SEF optimized URL. So I thought, what happens if we cache succesful SELECT queries from the ArtioSEF #__redirection table? It's a good thing, because you get your account unbanned ;)
This is a core hack. You need to re-apply it if reinstalling or upgrading Joomla!. It's made and tested by me on Joomla 1.0.12 Here's what you need to do: Download database.modified , rename it to database.php and place it in your /includes folder (overwrite the existing file) OR -backup your includes/database.php -open your includes/database.php -locate the loadResult function. It should be at line 432 function loadResult() { delete everything between /**
* This method loads the first field of the first row returned by the query.
*
* @return The value returned in the query or null if the query failed.
*/AND /**
* Load an array of single field results into an array
*/, and paste this modified loadResult function instead: function loadResult() { $ret = null; /* * mod by teachmejoomla */ if(stripos($this->_sql,'mos_redirect')&&stripos($this->_sql,'select')!==false) { $cachename = md5($this->_sql); global $mosConfig_absolute_path; global $mosConfig_cachepath, $mosConfig_cachetime; require_once( $mosConfig_absolute_path . '/includes/Cache/Lite/Function.php' ); //echo $this->_sql; $lifetime=$mosConfig_cachetime; $cache = new Cache_Lite( array("cacheDir" => $mosConfig_cachepath, "lifeTime" => $lifetime) ); if ($cachedquery = $cache->get($cachename)) { //echo "CACHE HIT: $this->_sql<br />"; $row = unserialize($cachedquery); } else { //echo "CACHE MISS: $this->_sql<br />"; /* * moved */ if (!($cur = $this->query())) { $cache->delete(); return null; } /* * */ $row = mysql_fetch_row( $cur ); if ($row) $cache->save(serialize($row),$cachename); mysql_free_result( $cur ); //print_r($this->_cursor); } $ret = $row[0]; } else /* * */ { if (!($cur = $this->query())) { return null; } if ($row = mysql_fetch_row( $cur )) { $ret = $row[0]; } mysql_free_result( $cur ); } return $ret; } Save and enjoy!
1. Thank you...20-06-2007 16:43 jure ...for usefull tip.
Thanks, Bert. the hack is done at the Joomla database layer, so I suppose as long the table is called #__redirect, it will work with any artio SEF version This change does go much faster joomla, thanks staff. Does need to be used if I am running a website using Joomla! 1.0.15 and Artio JoomSEF 2.2.6? Write Comment |
||||
| Last Updated ( Tuesday, 27 May 2008 ) | ||||
Newsletter
Joomla stuff
Auto tags
ArtioSef
artio joomsef hack
perf hack
SEF Advance 2008 nulled for joomla 15
how to hack database
joomla cache function
joomla spam bot hack
/includes/Cache/Lite/Function.php
joomla, cache, refresh
akocomment 2.0 1.0.15
joomsef 3.0
akocomment "joomla cache"
Joomsef banned
artio cpu
joomsef hack







this site is good! Not only a importend anti spam bot, now I see a importend hack for Artio. Works this with all artio versions?
