How to check site speed for logged in users

How do I measure site speed for logged in users? The tools like pingdom, google page speed etc, check site speed for guests. the reason I ask is this.

My site is fast for guests because I have page caching. For logged in users, I don’t have the pages cached and hence it is extremely slow. The end result is that my most loyal visitors (logged in users) are getting a slow site. If I can accurate measure it, I can move towards fixing it. Appreciate the help.

Related posts

Leave a Reply

1 comment

  1. I handled this by creating a test user on the system (let’s call the login my_test_user) and then added an action hook on init to check the URL for a token, and if the token is found it logs in as the test user before running the rest of the page. You can use whatever you want as the token as long as it is long and random enough, but this is a decent generator. Keep in mind that you should be using this via SSL (but then again, so should your logins with password).

    From a security standpoint I would recommend hard coding the test user either in the code or as a constant in wp-config.php. If this is ever compromised, you don’t want the hacker to be able to log in as any user, and your test user should have limited permissions. Perhaps even consider another token/key to enable/disable the functionality based on a wp_option value and only turn on when testing.

    Once added to your functions.php you can use any URL in your tools appended with ?login_token=YOUR_LOGIN_TOKEN to view it as my_test_user.

    function auto_login() {
        $login_token = isset( $_GET['login_token'] )? $_GET['login_token'] : false;
        // get a UUID from http://www.uuidgenerator.net/
        if ( $login_token == 'ac88dc0e-72a8-4a22-abc0-fb5b5396c0ac' ){
            // The test user we want to log in
            $user_login = 'my_test_user';
            // Get the user info
            $user = get_user_by( 'login', $user_login );
    
            // Log the test user in automatically
            wp_set_current_user( $user->ID, $user_login );
            wp_set_auth_cookie( $user->ID );
            do_action( 'wp_login', $user_login );
        }
    }
    // Set with a priority of 1 so that it runs ASAP
    add_action( 'init', 'auto_login', 1 );