WordPress HTTPS (SSL)
Very slow on some sites. Multisite? Large number of URLs to parse? (6 posts)

  1. Scott Nelle
    Posted 1 year ago #

    I've had a few sites on my network that have been very slow, and I've determined that deactivating WordPress HTTPS makes them fast again. I've done some debugging and here's what I've found:

    * It's generating several hundred queries that look like "SELECT domain FROM wp_blogs" -- to me this looks like a query with a few pieces missing.

    * It doesn't appear to relate directly to the number of sites on the network. I'm seeing similar behavior on a network with ~40 sites and one with ~400 sites.

    * It DOES appear to correlate with the number of URLs on the page.

    * It impacts all pages on a site, not just those which are set to force SSL.

    * It slows the page build time down from a fraction of a second to anywhere from 5 to 10 seconds.

    Anyone else experienced similar problems? Any suggestions for how to fix it?

    My best guess: getLocalDomains is being run hundreds of times, executing this line:
    $multisite_hosts = $wpdb->get_col($wpdb->prepare("SELECT domain FROM " . $wpdb->blogs, NULL));

    Is the plugin checking every URL on the page? If so, could that query be done once and stored as a private variable in the class?

    Thanks for any insight!


  2. Scott Nelle
    Posted 1 year ago #

    I've spent a few more minutes looking at the plugin. I've modified the class WordPressHTTPS in lib/WordPressHTTPS.php in the following ways and seen significant performance gains:

    1. declare a protected property $multisite_hosts insude the class
    2. Modify getLocalDomains() something like the following:
    public function getLocalDomains() {
    	global $wpdb;
    	$hosts = array(
    	if ( is_multisite() && is_subdomain_install() ) {
    		if ( !isset($this->multisite_hosts) ) {
    			$this->multisite_hosts = $wpdb->get_col($wpdb->prepare("SELECT domain FROM " . $wpdb->blogs, NULL));
    		$hosts = array_merge($hosts, $this->multisite_hosts);
    	return $hosts;

    Having done that, I shaved a few hundred seemingly-unnecessary queries and about 5 seconds from my average page load. There's almost certainly an even better way to do this, but that's what I came up with at a glance.

  3. abriand
    Posted 1 year ago #

    I didn't test your patch but i noticed the same issue, i wonder why it's not fixed yet..

  4. RavanH
    Posted 1 year ago #

    Code contribution can be done over at https://github.com/Mvied/wordpress-https and I noticed a pull request regarding multisite at https://github.com/desrosj/wordpress-https/commit/3d40540b238512cc40a575070b2d473c9ea30ff7 but it's not merged (yet?) ...

  5. Jonathan Desrosiers
    Posted 1 year ago #

    The plugin author went to merge my pull request, but there were merge conflicts. I redid my commits and created a new pull request. It should be merged in soon.

  6. RavanH
    Posted 12 months ago #

    @Jonathan - does your pull request indeed cover this threads topic of inefficient domain parsing?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WordPress HTTPS (SSL)
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.