O Amazon CloudFront é uma rede de distribuição de conteúdo (CDN) que pode ajudá-lo a sobreviver a uma enorme quantidade de carga em um curto período de tempo. Qual é a maneira mais fácil de configurar o WordPress para hospedar seus arquivos (biblioteca de mídia, CSS, arquivos de plugins, tema) no S3/CloudFront?
(Atualmente, estou usando o W3 Total Cache para fazer isso.)
O plugin funciona bem; alternativa você pode usar uma função própria para substituir o bloginf () ao seu CDN-Url; Exemplo:
substitua o URL no conteúdo:
// replace content for CDN
if ( !function_exists('fb_add_static_content_url') ) {
function fb_add_static_content_url($content) {
if ( is_admin() ) // eigentlich überflüssig
return $content;
$wpurl = get_bloginfo('wpurl');
$search = array(
$wpurl . '/wp-content/images/',
$wpurl . '/wp-content/download/',
);
$replace = array(
'http://cdn1.bueltge.de/',
'http://cdn2.bueltge.de/',
);
return str_replace( $search, $replace, $content );
}
add_filter( 'the_content', 'fb_add_static_content_url' );
}
substitua stylesheet_directoy e outros:
// replace for CDN
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.bueltge.de/',
'http://cdn2.bueltge.de/',
'http://cdn3.bueltge.de/',
'http://cdn3.bueltge.de/',
);
return str_replace( $search, $replace, $info );
} else {
return $info;
}
}
add_filter( 'bloginfo_url', 'fb_add_static_wpurl', 9999, 2 );
}
substitua o template_directory e outro:
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.bueltge.de/',
'http://cdn2.bueltge.de/',
'http://cdn3.bueltge.de/',
'http://cdn3.bueltge.de/',
);
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' );
Eu acho que o W3 Total Cache Plugin pode ajudá-lo ..