WordPress优化提速

文章描述:

WordPress如何优化才能速度最快,大家可以采用以下方法来优化

WP优化步骤

首先分享一下我的建议以及可以优化速度的有效措施

  • 前端优化:使用CDN加速
  • 前端优化:图片使用OSS/COS等第三方储存
  • 后端优化:推荐使用Redis或Memcached缓存功能,和opcache进行PHP加速优化
  • 后端优化:禁用一些WordPressAPI的自动更新任务及禁用谷歌字体

 

宝塔面板优化

这儿针对宝塔面板,提供一些优化建议。

首先PHP环境使用7.0版本数据库5.6以上最好

PHP扩展开启Redis和opcache拓展

宝塔软件商店里面下载安装Redis软件

 

找到session配置,将缓存模式切换为redis(注意需要在服务器运营商哪里把6379进行放端)

 

数据库方面在数据库性能设置,选择适合自己的服务器的优化方案

 

 

wp后台方面

在将下面代码添加到主题functions.php文件中:此步骤目的为禁用一些api的自动更新任务和关闭谷歌字体

// 关闭谷歌字体
function xintheme_remove_gutenberg_styles($translation, $text, $context, $domain)
{
if($context != 'Google Font Name and Variants' || $text != 'Noto Serif:400,400i,700,700i') {
return $translation;
}
return 'off';
}
// 彻底关闭自动更新
add_filter('automatic_updater_disabled', '__return_true');
// 关闭更新检查定时作业
remove_action('init', 'wp_schedule_update_checks');
// 移除已有的版本检查定时作业
wp_clear_scheduled_hook('wp_version_check');
// 移除已有的插件更新定时作业
wp_clear_scheduled_hook('wp_update_plugins');
// 移除已有的主题更新定时作业
wp_clear_scheduled_hook('wp_update_themes');
// 移除已有的自动更新定时作业
wp_clear_scheduled_hook('wp_maybe_auto_update');
// 移除后台内核更新检查
remove_action( 'admin_init', '_maybe_update_core' );
// 移除后台插件更新检查
remove_action( 'load-plugins.php', 'wp_update_plugins' );
remove_action( 'load-update.php', 'wp_update_plugins' );
remove_action( 'load-update-core.php', 'wp_update_plugins' );
remove_action( 'admin_init', '_maybe_update_plugins' );
// 移除后台主题更新检查
remove_action( 'load-themes.php', 'wp_update_themes' );
remove_action( 'load-update.php', 'wp_update_themes' );
remove_action( 'load-update-core.php', 'wp_update_themes' );
remove_action( 'admin_init', '_maybe_update_themes' );

 

也可以安装一些插件加速

wp火箭

WP Rocket –最佳WordPress缓存插件 v3.11.3

下载地址:https://updog.cc/share/hb5psTuSo33Pdc01/file

 

 

发布时间:2022/08/23

发表评论