Speeding up Joomla!'s search results |
| Thursday, 18 January 2007 | ||||
|
First of all why would you cache Joomla! search results? $results = $_MAMBOTS->trigger( 'onSearch', array( $searchword, $phrase, $ordering ) );Empty this line, then select and copy the following text: // search result caching hack by teachmejoomla /***********************************************************************/ global $mosConfig_cachepath; require_once( $mosConfig_absolute_path . '/includes/Cache/Lite/Function.php' ); $lifetime=86400; $cache = new Cache_Lite( array("cacheDir" => $mosConfig_cachepath."/", "lifeTime" => $lifetime) ); if ($cachedquery = $cache->get("searchcache_" . $searchword_clean . $phrase . $ordering) ) { $results=unserialize($cachedquery); // echo "<h1>Cache hit on $searchword_clean . $phrase . $ordering</h1>" ; } else { //MOVED $results = $_MAMBOTS->trigger( 'onSearch', array( $searchword, $phrase, $ordering ) ); //MOVED $searchcache=serialize($results); //echo $searchcache; $cache->save($searchcache,"searchcache_" . $searchword_clean . $phrase . $ordering); } /***********************************************************************/ , and paste it in your (search.php) editor window at cursor position. that's it, you're done. A few notes The hack stores results for $lifetime seconds, as a serialized PHP variable. On the first search for a keyword/keyphrase, the results are pulled from the database and stored in Joomla's cache folder. On subsequent searches, the results are shown directly from cache, eliminating the SQL overhead. If $lifetime seconds passed since the phrase was searched, the cache is cleaned and renewed automatically. Enjoy!
Write Comment |
||||
| Last Updated ( Thursday, 18 January 2007 ) | ||||
Joomla stuff
Newsletter
Auto tags
joomla search cache
joomla com_search howto
com_search joomla
joomla $results in array
joomla search nofollow
alter search in joomla
speed up joomla component
joomla caching search results
joomla searches result
Hack H1 de Joomla
joomla keyword
php +cache +lite +joomla
joomla + cache + folder
joomla search ordering
Cache Folder joomla!
speed up joomla db
joomla com search speed
joomla security cache folder
hack joomla com_search
joomla keyword function
php cache search results
joomla + keyword search








