对于多站点,请使用最小64MB Ram的Web空间,并在Apache上使用APC和Memcached,缓存不是静态的,您可以毫无问题地使用所有WP函数。您可以通过PageSpeed读取其他选项进行扫描,主题中有编码。缓存可以做得很好,但不能修复坏的主题或插件。另一种解决方案是在WordPress中使用没有Cookie的子域作为CDN。将其添加到wp配置中。php仅用于域上的Cookie,而不用于子域。
define( \'COOKIE_DOMAIN\', \'example.com\' );
现在在函数中设置新函数。php的主题或写一个插件来替换路径形式的静态内容到您的子域,您的自定义CDN。
// replace for CDN on bloginfo
if ( !function_exists(\'fb_add_static_wpurl\') ) {
function fb_add_static_wpurl($info, $show) {
if ( is_admin() )
return $info;
$keys = array(
\'url\',
\'wpurl\',
\'stylesheet_url\',
\'stylesheet_directory\',
\'template_url\',
\'template_directory\',
);
if ( in_array( $show, $keys ) ) {
$wpurl = get_bloginfo(\'wpurl\');
$search = array(
$wpurl . \'/wp-content/images/\',
$wpurl . \'/wp-content/download/\',
$wpurl . \'/wp-content/themes/\',
$wpurl . \'/wp-content/plugins/\',
);
$replace = array(
\'http://cdn1.example.com/\',
\'http://cdn2.example.com/\',
\'http://cdn3.example.com/\',
\'http://cdn4.example.com/\',
);
return str_replace( $search, $replace, $info );
} else {
return $info;
}
}
add_filter( \'bloginfo_url\', \'fb_add_static_wpurl\', 9999, 2 );
}
现在,模板和样式表路径的函数
function fb_add_static_stylesheet_uri($uri) {
if ( is_admin() )
return $uri;
$wpurl = get_bloginfo(\'wpurl\');
$search = array(
$wpurl . \'/wp-content/images/\',
$wpurl . \'/wp-content/download/\',
$wpurl . \'/wp-content/themes/\',
$wpurl . \'/wp-content/plugins/\',
);
$replace = array(
\'http://cdn1.example.com/\',
\'http://cdn2.example.com/\',
\'http://cdn3.example.com/\',
\'http://cdn4.example.com/\',
);
return str_replace( $search, $replace, $uri );
}
add_filter ( \'template_directory_uri\', \'fb_add_static_stylesheet_uri\' );
add_filter ( \'stylesheet_uri\', \'fb_add_static_stylesheet_uri\' );
add_filter ( \'stylesheet_directory_uri\', \'fb_add_static_stylesheet_uri\' );
现在读取前端静态CDN URL上的页面速度,无需cookie。
还将以下源添加到。块副本内容的htaccess:
##
# Explicitly send a 404 header if a file on cdn[0-9].example.org is not
# found. This will prevent the start page (empty URL) from being loaded.
##
RewriteCond %{HTTP_HOST} ^cdn[0-9]\\.example\\.org [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* - [R=404,L]
##
# Do not dispatch dynamic resources via cdn[0-9].example.org.
##
RewriteCond %{HTTP_HOST} ^cdn[0-9]\\.example\\.org [NC]
RewriteCond %{REQUEST_FILENAME} \\.(php|html)$
RewriteRule .* - [R=404,L]
请使用函数,也是示例,您可以用我的想法编写您的解决方案。