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!
Related articles(beta):
Does need to be used if I am running a website using Joomla! 1.0.15 and Artio JoomSEF 2.2.6? 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
Write Comment |
||||
| Last Updated ( Tuesday, 27 May 2008 ) | ||||
Joomla stuff
Newsletter
Auto tags
artio sef performance
artio sef joomla cache
performance hacker download]
hacker deleting first row of database
A perf hack
joomla nested categories sef
artiosef patch
sef advance dawnload
joom sef nulled
artio joomsef joomla 1.0.15 nulled
joomsef hack null
download SEF Advance null
teach me how to hack
joomla cache nulled
artio sef joomla patch spam
performance joomsef
hacking 1.0.12 joomla
advance sef hack
Joomla nested sliding modules download
artiosef performance
sef advance delete table
joomla ArtioSEF







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?