遨遊飛翔 | 學習筆記 For php、jQuery、MySql、Centos、Suse、Server

一月/10

8

Cache_Lite cache php export html

Cache_Lite 是一個簡單又好用的cache套件,當網站流量的大時候或是,或是不需要每次更新PHP產生的HTML時,這時候加個CACHE就可以減少PHP跟資料庫要資料連線次數,就可以加快網頁讀取的速度了 準備: Cache_Lite 下載此套件

使用:

require_once(APP_REAL_PATH.'/Cache_Lite-1.7.8/Lite.php');
 
$Cache_Lite = new Cache_Lite(array('cacheDir'=>'存放cache位置','lifeTime' =>'cache存活時間'));
 
if($data = $Cache_Lite->get('cache代號')){
	echo $data;
}
else{
	ob_start();
 
	HTML...
 
	// 將存在緩衝區的html內容存入cache
	$Cache_Lite->save(ob_get_contents());
 
	ob_end_flush();
}

結論: 使用 Cache_Lite 來當作網站的cache,雖然只是個很簡單的運用,不過對於網站提升速度相當有幫助。

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Hemidemi
  • Live
  • email
  • TwitThis
  • Twitter

相關文章

  • 沒有相關文章

RSS Feed

仍無迴響。

Leave a comment!

<<

>>

Get Adobe Flash playerPlugin by wpburn.com wordpress themes

Find it!

Theme Design by devolux.org