';
		wp_nonce_field('wp-cache');
		echo "\n";
	}
}
然后在处理提交函数添加memcache操作代码,这里有一个前提,是已经安装了object-cache.php,因为这里面定义了全局的memcache操作变量。然后在该wp_cache_files函数中添加以下代码。
global $wp_object_cache;
			$wp_object_cache->flush();
最终效果图:

至此结束!
不过有时候不想删除静态的html文件只想更新缓存,我就把wp-supercache稍微改了下,把测试缓存的改成了删除memcache,这个测试感觉没啥用。至少我没用过。修改过后代码。大约在1162行左右。
				if ( array_key_exists('action', $_POST) && $_POST[ 'action' ] == 'test' && $valid_nonce ) {
					//清空MemCache
					global $wp_object_cache;
					$wp_object_cache->flush();
					echo 'Memcached成功清除';
					/*
					$url = trailingslashit( get_bloginfo( 'url' ) );
					if ( isset( $_POST[ 'httponly' ] ) )
						$url = str_replace( 'https://', 'http://', $url );
					// Prime the cache
					echo "
" . sprintf(  __( 'Fetching %s to prime cache: ', 'wp-super-cache' ), $url );
					$page = wp_remote_get( $url, array('timeout' => 60, 'blocking' => true ) );
					echo '' . __( 'OK', 'wp-super-cache' ) . '
';
					sleep( 1 );
					// Get the first copy
					echo "
" . sprintf(  __( 'Fetching first copy of %s: ', 'wp-super-cache' ), $url );
					$page = wp_remote_get( $url, array('timeout' => 60, 'blocking' => true ) );
					if ( !is_wp_error( $page ) ) {
						$fp = fopen( $cache_path . "1.html", "w" );
						fwrite( $fp, $page[ 'body' ] );
						fclose( $fp );
						echo '' . __( 'OK', 'wp-super-cache' ) . " (1.html)
";
						sleep( 1 );
					} else {
						echo '' . __( 'FAILED', 'wp-super-cache' ) . "
";
					}
					// Get the second copy
					echo "
" . sprintf(  __( 'Fetching second copy of %s: ', 'wp-super-cache' ), $url );
					$page2 = wp_remote_get( $url, array('timeout' => 60, 'blocking' => true ) );
					if ( !is_wp_error( $page2 ) ) {
						$fp = fopen( $cache_path . "2.html", "w" );
						fwrite( $fp, $page2[ 'body' ] );
						fclose( $fp );
						echo '' . __( 'OK', 'wp-super-cache' ) . " (2.html)
";
					} else {
						echo '' . __( 'FAILED', 'wp-super-cache' ) . "
";
					}
					if ( is_wp_error( $page ) || is_wp_error( $page2 ) || $page[ 'response' ][ 'code' ] != 200 || $page2[ 'response' ][ 'code' ] != 200 ) {
						echo '
' . __( 'One or more page requests failed:', 'wp-super-cache' ) . '
';
						$error = false;
						if ( is_wp_error( $page ) ) {
							$error = $page;
						} elseif ( is_wp_error( $page2 ) ) {
							$error = $page2;
						}
						if ( $error ) {
							$errors = '';
							$messages = '';
							foreach ( $error->get_error_codes() as $code ) {
								$severity = $error->get_error_data($code);
								foreach ( $error->get_error_messages( $code ) as $err ) {
									$errors .= '	' . $err . "
\n";
								}
							}
							if ( !empty($err) )
								echo '' . $errors . "
\n";
						} else {
							echo '- ' . sprintf( __( 'Page %d: %d (%s)', 'wp-super-cache' ), 1, $page[ 'response' ][ 'code' ], $page[ 'response' ][ 'message' ] ) . '';
							echo '
- ' . sprintf( __( 'Page %d: %d (%s)', 'wp-super-cache' ), 2, $page2[ 'response' ][ 'code' ], $page2[ 'response' ][ 'message' ] ) . '
';
						}
					}
					if ( ( !is_wp_error( $page ) && !is_wp_error( $page2 ) ) && preg_match( '/(Cached page generated by WP-Super-Cache on) ([0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*)/', $page[ 'body' ], $matches1 ) &&
							preg_match( '/(Cached page generated by WP-Super-Cache on) ([0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*)/', $page2[ 'body' ], $matches2 ) && $matches1[2] == $matches2[2] ) {
						echo '
' . sprintf( __( 'Page 1: %s', 'wp-super-cache' ), $matches1[ 2 ] ) . '
';
						echo '
' . sprintf( __( 'Page 2: %s', 'wp-super-cache' ), $matches2[ 2 ] ) . '
';
						echo '
' . __( 'The timestamps on both pages match!', 'wp-super-cache' ) . '
';
					} else {
						echo '
' . __( 'The pages do not match! Timestamps differ or were not found!', 'wp-super-cache' ) . '
';
						echo '
' . __( 'Things you can do:', 'wp-super-cache' ) . '
';
						echo '- ' . __( 'Load your homepage in a logged out browser, check the timestamp at the end of the html source. Load the page again and compare the timestamp. Caching is working if the timestamps match.', 'wp-super-cache' ) . '';
						echo '
- ' . __( 'Enable logging on the Debug page here. That should help you track down the problem.', 'wp-super-cache' ) . '';
						echo '
- ' . __( 'You should check Page 1 and Page 2 above for errors. Your local server configuration may not allow your website to access itself.', 'wp-super-cache' ) . '';
						echo "
";
					}
					*/
				}
				echo ''; 本文链接:http://it72.com/6820.htm