Index: trunk/include/xpress_block_render.php
===================================================================
--- trunk/include/xpress_block_render.php	(revision 134)
+++ trunk/include/xpress_block_render.php	(revision 135)
@@ -158,3 +158,72 @@
 	}
 	
+	function xpress_block_cache_refresh()
+	{
+		global $xoops_db;
+		$mid = get_xpress_modid();
+		$sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = $mid AND visible = 1";
+		$blocks = $xoops_db->get_results($sql);
+		$mydirname = get_xpress_dir_name();
+		require_once get_xpress_dir_path() . '/include/xpress_block_render.php';
+
+		foreach($blocks as $block){
+			$func_file = $block->func_file;
+			$call_theme_function_name = str_replace(".php", "", $func_file);
+			$inc_theme_file_name = str_replace(".php", "", $func_file) . '_theme.php';
+			$cache_title = str_replace(".php", "", $func_file);
+			$blockID = $block->bid;
+			$options = explode("|", $block->options);
+
+			$block_theme_file = get_block_file_path($mydirname,$inc_theme_file_name);
+			require_once $block_theme_file;
+			$render = $call_theme_function_name($options);		//The block name and the called function name should be assumed to be the same name. 			
+			$render_array['block'] = $render;
+			$render_array['block']['options'] = $block->options;
+			if (xpress_block_cache_found($mydirname,$cache_title. $blockID)){	
+				$render_serialize = xpress_XML_serialize($render_array);
+				$render_md5 = md5($render_serialize);
+
+				$cache_serialize = xpress_cache_read($mydirname,$cache_title. $blockID.'.xml');
+				$cache_md5 = md5($cache_serialize);
+				
+				if ($render_md5 != $cache_md5){
+					xpress_block_cache_write($mydirname,$cache_title. $blockID, $render_array);
+				}
+			} else {
+				xpress_block_cache_write($mydirname,$cache_title. $blockID, $render_array);
+			}
+		}
+	}
+	
+	function xpress_unnecessary_block_cache_delete()
+	{
+		global $xoops_db,$xoops_config;
+		$mid = get_xpress_modid();
+		$sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = $mid AND visible = 1";
+		$blocks = $xoops_db->get_results($sql);
+		$mydirname = get_xpress_dir_name();
+		require_once get_xpress_dir_path() . '/include/xpress_block_render.php';
+
+		$pattern ='';
+		foreach($blocks as $block){
+			$cache_file_name = $mydirname . '_'. str_replace(".php", "", $block->func_file) . $block->bid;
+			if (!empty($pattern))  $pattern .= '|';
+			$pattern .= $cache_file_name;
+		}
+		$pattern = '(' . $pattern . ')';
+		
+		$cache_dir = $xoops_config->xoops_root_path . '/cache/';
+		$cache_time = 0;
+        if ($dh = opendir($cache_dir)) {
+            while (($file = readdir($dh)) !== false) {
+                if (preg_match('/^' . preg_quote($mydirname) . '/', $file)) {
+                	if(! preg_match('/' . $pattern . '/', $file)) {
+                    	unlink($cache_dir.$file);
+                    }
+                } 
+            } 
+            closedir($dh);
+        } 
+    } 
+	
 ?>
Index: trunk/include/xpress_templates_make.php
===================================================================
--- trunk/include/xpress_templates_make.php	(revision 134)
+++ trunk/include/xpress_templates_make.php	(revision 135)
@@ -86,4 +86,5 @@
 		'meta_block.html' ,
 		'sidebar_block.html' ,
+		'widget_block.html' ,
 		'index.html',
 	);
Index: trunk/wp-config.php
===================================================================
--- trunk/wp-config.php	(revision 134)
+++ trunk/wp-config.php	(revision 135)
@@ -95,5 +95,6 @@
 	//When adding, and changing and deleting Post & Comment, block cache is refreshed by add_action at any time. 
 	// This Function in xpressme plugin
-	if (!is_block_cache_normal()) block_cache_refresh();
+	xpress_unnecessary_block_cache_delete();
+	if (is_home()) xpress_block_cache_refresh();
 	exit();		// The return to wp-blog-header.php is stolen here
 }
Index: trunk/wp-content/plugins/xpressme/include/xpress_common_functions.php
===================================================================
--- trunk/wp-content/plugins/xpressme/include/xpress_common_functions.php	(revision 134)
+++ trunk/wp-content/plugins/xpressme/include/xpress_common_functions.php	(revision 135)
@@ -113,85 +113,4 @@
 		return false;
 	}
-	
-}
-
-
-function is_block_cache_found($block_name)
-{
-	global $xoops_config;
-	$mydirname = get_xpress_dir_name();
-
-	if(defined('XOOPS_ROOT_PATH')){
-		$cache_dir = XOOPS_ROOT_PATH . '/cache/';
-	} else {
-		$cache_dir = $xoops_config->xoops_root_path . '/cache/';
-	}
-	$xml_name = $block_name . '.xml';
-
-    $filename = $cache_dir .$mydirname . '_' . $xml_name;
-	$cache_time = 0;
-//        if (file_exists($filename) && ((time() - filemtime($filename)) < $cache_time)) {
-    if (file_exists($filename)) {
-        return true;
-        } else {
-		return false;
-	}
-}
-
-
-//When there is no block cash, and an optional block is different, false is returned.
-function is_block_cache_normal()
-{
-	global $xoops_config;
-	global $xoops_db;
-	$mid = get_xpress_modid();
-	$sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = $mid ";
-	$blocks = $xoops_db->get_results($sql);
-	$mydirname = get_xpress_dir_name();
-	require_once get_xpress_dir_path() . '/include/xpress_block_render.php';
-
-	foreach($blocks as $block){
-		$func_file = $block->func_file;
-		$call_theme_function_name = str_replace(".php", "", $func_file);
-		$inc_theme_file_name = str_replace(".php", "", $func_file) . '_theme.php';
-		$cache_title = str_replace(".php", "", $func_file);
-		$blockID = $block->bid;
-		$options = explode("|", $block->options);
-		
-		if (!is_block_cache_found($cache_title . $blockID)) return false;
-		$xml = xpress_block_cache_read($mydirname,$cache_title. $blockID);
-		$options = '';
-		$options = @$xml['block']['options'];
-		if( strcmp($options,$block->options) != 0 ) return false;
-	}
-	return true;
-}
-
-
-function block_cache_refresh()
-{
-	global $xoops_db;
-	$mid = get_xpress_modid();
-	$sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = $mid";
-	$blocks = $xoops_db->get_results($sql);
-	$mydirname = get_xpress_dir_name();
-	require_once get_xpress_dir_path() . '/include/xpress_block_render.php';
-
-
-	foreach($blocks as $block){
-		$func_file = $block->func_file;
-		$call_theme_function_name = str_replace(".php", "", $func_file);
-		$inc_theme_file_name = str_replace(".php", "", $func_file) . '_theme.php';
-		$cache_title = str_replace(".php", "", $func_file);
-		$blockID = $block->bid;
-		$options = explode("|", $block->options);
-
-		$block_theme_file = get_block_file_path($mydirname,$inc_theme_file_name);
-		require_once $block_theme_file;
-		$block_render = $call_theme_function_name($options);		//The block name and the called function name should be assumed to be the same name. 			
-		$xml['block'] = $block_render;
-		$xml['block']['options'] = $block->options;
-		xpress_block_cache_write($mydirname,$cache_title. $blockID, $xml);
-	}
 }
 
Index: trunk/wp-content/themes/xpress_default/blocks/block_style.css
===================================================================
--- trunk/wp-content/themes/xpress_default/blocks/block_style.css	(revision 134)
+++ trunk/wp-content/themes/xpress_default/blocks/block_style.css	(revision 135)
@@ -323,2 +323,10 @@
 
 }
+/*********** widget block ***************/
+.xpress_widget_block {
+
+}
+.xpress_widget_block h2{
+	font-size: 10pt;
+
+}
