TeachMeJoomla
Speeding up Joomla!'s search results |
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! Add as favourites (0)
Powered by AkoComment Tweaked Special Edition v.1.4.2 |
Login Form
Top SE queries for this URL
speeding up joomla
Joomla books
Are you secure?
Satisfied?Click below to buy world's best anti virus