12

We have many WP sites with a proxy in between the servers that they sit on and the internet.

Some things in WP simply don't work:

  • RSS feeds on dashboard
  • looking up themes
  • looking up plugins
  • core updates

We do everything manually and there are really no issues except for SLOWNESS on page loads. It seems that almost everything in admin take 4-5 seconds to process except for adding media - which is surprisingly fast.

What are some initial things I can check or do to speed up the back-end? (the front-end flies)

  • 3
    You can block external requests by defining define( 'WP_HTTP_BLOCK_EXTERNAL', true ); in wp-config.php. Also WordPress admin enqueues Open Sans and other fonts from Google. You can disable that too. It makes load admin section a little faster. – Robert hue Oct 28 '14 at 15:53
  • @Roberthue - it almost seems that a lot of the pages in admin are making calls out to the web. We would like to turn all of them off. Adding the external request blocking now to see how it reacts. – STing Oct 28 '14 at 16:04
  • 1
    @Roberthue - Not sure why I have never used this before - do you know when WP_HTTP_BLOCK_EXTERNAL was first implemented. I added it to my plugin (have a plugin I propogate everywhere) and there is way way quicker to load all pages. Please add this as an answer and any other tips for the gridless. – STing Oct 28 '14 at 16:15
  • It's been there for couple of years. Not sure exactly when was it added. I was also looking for ways to speedup admin pages when I found this article – Robert hue Oct 28 '14 at 16:53
  • 1
    As an answer please. Also it have been in for a very long time, probably (nearly) as long as HTTP API itself. – Rarst Oct 28 '14 at 17:53
12

jQuery / JavaScript in the footer

One thing you can do is to move jQuery to the footer blog post. It's per default not needed in the header. You will have check if everything still works tough, as I normally just do that for themes:

<?php
/* Plugin Name: Move jQuery to the footer */
function( 'admin_enqueue_scripts', function( $hook )
{
    $GLOBALS['wp_scripts']->add_data( 'jquery', 'group', 1 );
} );

Queries

Another thing that speeds up the post list table screens is to reduce the number of queried fields. I noticed that problem a while ago when those screens were getting loaded too slow due to my 999 posts settings. Full blog post here - Plugin as GitHub Gist.

<?php
/**
 * Plugin Name: (WCM) Faster Admin Post Lists
 * AuthorURL:   http://unserkaiser.com
 * License:     MIT
 */

add_filter( 'posts_fields', 'wcm_limit_post_fields_cb', 0, 2 );
function wcm_limit_post_fields_cb( $fields, $query )
{
  if (
        ! is_admin()
        OR ! $query->is_main_query()
        OR ( defined( 'DOING_AJAX' ) AND DOING_AJAX )
        OR ( defined( 'DOING_CRON' ) AND DOING_CRON )
    )
        return $fields;

    $p = $GLOBALS['wpdb']->posts;
    return implode( ",", array(
        "{$p}.ID",
        "{$p}.post_date",
        "{$p}.post_name",
        "{$p}.post_title",
        "{$p}.ping_status",
        "{$p}.post_author",
        "{$p}.post_password",
        "{$p}.comment_status",
    ) );
}

If you don't need all columns, you could extend above plugin with removing the contents of some columns as well.

add_filter( 'manage_edit-post_columns', function( $columns )
{
    # @TODO Remove columns which you don't need
    return $defaults;
} );

Dashboard

Every user enters at the dashboard - which is probably the slowest part in the admin UI. You could deactivate some widgets that you don't need, instead of just hiding them:

<?php
/** Plugin Name: Remove Dashboard Widgets */
add_action( 'wp_dashboard_setup', function()
{
    remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' );
    remove_meta_box( 'dashboard_primary', 'dashboard', 'normal' );
    remove_meta_box( 'dashboard_primary', 'dashboard', 'side' );
    remove_meta_box( 'dashboard_activity', 'dashboard', 'normal' );
    remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' );
    remove_meta_box( 'dashboard_secondary', 'dashboard', 'normal' );
    remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
    remove_meta_box( 'dashboard_browser_nag', 'dashboard', 'normal' );
    remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'side' );
    remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
    remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
    remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
} );

Outgoing data

I can just recommend using Snitch by Sergej Müller to monitor what data tries to leave your installation. The plugin allows to suppress all or just specific connections as well as pin point specific internal connections that target tasks like unwanted cron jobs and similar things. You can look at its source for examples if you don't want the full package. Sergej normally writes very readable code with a generous white space usage.

  • 1
    You can also geht useful Informationen via the Plugin Debug Objects to see, which queries, functions was fired and how long run she. Also from which function, plugin comes the query. – bueltge Feb 12 '15 at 16:06
4

I recommend installing this https://github.com/johnbillion/query-monitor and looking at the following: Memory usage, HTTP requests, AJAX and slow queries.

It could be your revisions, a plugin's AJAX, a bad query, etc.

You will be able to see if you need to add more RAM to your server which usually solves a lot of slow loading admin issues, especially if you have multiple editors in the admin.

But besides some tricks here and there there is no all in one solution, you need to check out how themes are plugins are interacting with the admin.

2

Along with some of the well suggested answers above you could limit or disable wordpress "heartbeat" which can dramatically slow down your admin if you have a lot of screens open or many users using at once. Several hosts like WP-Engine actually have a variation of this setup automatically.

function optimize_heartbeat_settings( $settings ) {
    $settings['autostart'] = false;
    $settings['interval'] = 60;
    return $settings;
}
add_filter( 'heartbeat_settings', 'optimize_heartbeat_settings' );

function disable_heartbeat_unless_post_edit_screen() {
    global $pagenow;
    if ( $pagenow != 'post.php' && $pagenow != 'post-new.php' )
        wp_deregister_script('heartbeat');
}
add_action( 'init', 'disable_heartbeat_unless_post_edit_screen', 1 );

One other thing you might try is tinkering with some of the wp-config.php constants. Turning off post revisions would without question help, but if you don't want to do do that you could at least limit the revisions.

define('WP_POST_REVISIONS', 5);

Two others constants I usually change to keep things optimized is the empty trash and autosave ones.

define('AUTOSAVE_INTERVAL', 600);
define( 'EMPTY_TRASH_DAYS', 3 );
  • No problem. Added a few more options as well. – Bryan Willis Mar 30 '16 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.