fixes in error logging and refresh cache issues
diff --git a/erpnext/website/web_cache.py b/erpnext/website/web_cache.py
index 8da38e5..893f7f2 100644
--- a/erpnext/website/web_cache.py
+++ b/erpnext/website/web_cache.py
@@ -225,6 +225,8 @@
 	
 	# webnotes.conn.sql("delete from `tabWeb Cache`")
 	
+	clear_cache(None)
+	
 	query_map = {
 		'Web Page': """select page_name, name from `tabWeb Page` where docstatus=0""",
 		'Blog': """\
@@ -236,12 +238,11 @@
 	}
 
 	for dt in query_map:
-		for result in webnotes.conn.sql(query_map[dt], as_dict=1):
-			create_cache(result['page_name'], dt, result['name'])
-			clear_cache(result['page_name'], dt, result['name'])
-			if build and dt in build: load_into_cache(result['page_name'])
+		if build and dt in build: 
+			for result in webnotes.conn.sql(query_map[dt], as_dict=1):
+				create_cache(result['page_name'], dt, result['name'])
+				load_into_cache(result['page_name'])
 			
 	for page_name in get_predefined_pages():
 		create_cache(page_name, None, None)
-		clear_cache(page_name, None, None)
 		if build: load_into_cache(page_name)
\ No newline at end of file