解决WORDPRESS运行慢,占内存的方法

WORDPRESS运行慢或小vps还背不起了,这些是什么原因呢,下面我们整理了一些关于导致WORDPRESS运行慢,占内存问题的解决办法.

很多人会吐槽wordpress运行慢,占内存,的确如此,wordpress比同类程序要耗资源多一些,我们看看wordpress启动加载了哪些文件就知道原因了.

我们看看wp-settiings.php文件:

  1. // Attach the default filters.
  2. require( ABSPATH . WPINC . '/default-filters.php' );
  3. // Initialize multisite if enabled.
  4. if ( is_multisite() ) {
  5. require( ABSPATH . WPINC . '/ms-blogs.php' );
  6. require( ABSPATH . WPINC . '/ms-settings.php' );
  7. } elseif ( ! defined( 'MULTISITE' ) ) {
  8. define( 'MULTISITE', false );
  9. }
  10. register_shutdown_function( 'shutdown_action_hook' );
  11. // Stop most of WordPress from being loaded if we just want the basics.
  12. if ( SHORTINIT )
  13. return false;
  14. // Load the L10n library.
  15. require_once( ABSPATH . WPINC . '/l10n.php' );
  16. // Run the installer if WordPress is not installed.
  17. wp_not_installed();
  18. // Load most of WordPress.
  19. require( ABSPATH . WPINC . '/class-wp-walker.php' );
  20. require( ABSPATH . WPINC . '/class-wp-ajax-response.php' );
  21. require( ABSPATH . WPINC . '/formatting.php' );
  22. require( ABSPATH . WPINC . '/capabilities.php' );
  23. require( ABSPATH . WPINC . '/query.php' );
  24. require( ABSPATH . WPINC . '/date.php' );
  25. require( ABSPATH . WPINC . '/theme.php' );
  26. require( ABSPATH . WPINC . '/class-wp-theme.php' );
  27. require( ABSPATH . WPINC . '/template.php' );
  28. require( ABSPATH . WPINC . '/user.php' );
  29. require( ABSPATH . WPINC . '/session.php' );
  30. require( ABSPATH . WPINC . '/meta.php' );
  31. require( ABSPATH . WPINC . '/general-template.php' );
  32. require( ABSPATH . WPINC . '/link-template.php' );
  33. require( ABSPATH . WPINC . '/author-template.php' );
  34. require( ABSPATH . WPINC . '/post.php' );
  35. require( ABSPATH . WPINC . '/post-template.php' );
  36. require( ABSPATH . WPINC . '/revision.php' );
  37. require( ABSPATH . WPINC . '/post-formats.php' );
  38. require( ABSPATH . WPINC . '/post-thumbnail-template.php' );
  39. require( ABSPATH . WPINC . '/category.php' );
  40. require( ABSPATH . WPINC . '/category-template.php' );
  41. require( ABSPATH . WPINC . '/comment.php' );
  42. require( ABSPATH . WPINC . '/comment-template.php' );
  43. require( ABSPATH . WPINC . '/rewrite.php' );
  44. require( ABSPATH . WPINC . '/feed.php' );
  45. require( ABSPATH . WPINC . '/bookmark.php' );
  46. require( ABSPATH . WPINC . '/bookmark-template.php' );
  47. require( ABSPATH . WPINC . '/kses.php' );
  48. require( ABSPATH . WPINC . '/cron.php' );
  49. require( ABSPATH . WPINC . '/deprecated.php' );
  50. require( ABSPATH . WPINC . '/script-loader.php' );
  51. require( ABSPATH . WPINC . '/taxonomy.php' );
  52. require( ABSPATH . WPINC . '/update.php' );
  53. require( ABSPATH . WPINC . '/canonical.php' );
  54. require( ABSPATH . WPINC . '/shortcodes.php' );
  55. require( ABSPATH . WPINC . '/class-wp-embed.php' );
  56. require( ABSPATH . WPINC . '/media.php' );
  57. require( ABSPATH . WPINC . '/http.php' );
  58. require( ABSPATH . WPINC . '/class-http.php' );
  59. require( ABSPATH . WPINC . '/widgets.php' );
  60. require( ABSPATH . WPINC . '/nav-menu.php' );
  61. require( ABSPATH . WPINC . '/nav-menu-template.php' );
  62. require( ABSPATH . WPINC . '/admin-bar.php' );
  63. //phpfensi.com
  64. // Load multisite-specific files.
  65. if ( is_multisite() ) {
  66. require( ABSPATH . WPINC . '/ms-functions.php' );
  67. require( ABSPATH . WPINC . '/ms-default-filters.php' );
  68. require( ABSPATH . WPINC . '/ms-deprecated.php' );
  69. }

wordpress在启动的时候就默认加载了这么多文件,运行过程中根据插件和主题也加载其他的文件,也许你根本没用到这些文件中的类或者方法.

如何优化wordpress的速度?

用wordpress不用缓存插件的话,那简直无法想象那速度,优化wordpress速度,一定要用缓存.

另外不要过多使用插件,特别是质量低的插件,如果是开发者,多利用wordpress自带的cache函数.

还有一点特殊情况,在国内不能访问谷歌字体和头像服务,要替换成国内的字体镜像,具体方法搜索本站.