• Hello, thanks for the usefull plugin.
    After I started to use the plugin more intensive with more than 10 pictures on the main blog site, I realized perfomance lags. It takes about 30-40 seconds for loading of any stuff on the site (white webpage, different client and internet connections). Once the site begins to load, the pictures come quickly. The site loads instantly if I deactivate the onedrive plugin.

    Plugin Version is 1.2.6
    Wordpress 4.0.1
    Are there known performance issues for this plugin?

    Cheers
    leberwurst79

    https://www.ads-software.com/plugins/pwebonedrive/

Viewing 6 replies - 1 through 6 (of 6 total)
  • It’s also very slow for me too. I’m just testing this plugin out for now. I love everything about this plugin except that it’s very slow. It seems to be running a lot of ajax requests on admin-ajax.php. Each image is an ajax request. I wonder if there’s a better way to go about this, though I don’t know of any myself. It’s all new to me.

    It takes 2-6 seconds for one image to load. If there are more than one image, each image adds up. Normally it takes one second, or less to load all the images on a page, even using Flickr integration. I’m not sure how to help though. I know OneDrive itself is pretty fast. Maybe caching the ajax requests on the server may help.

    Thread Starter leberwurst79

    (@leberwurst79)

    Jo… with that plugin things happen before loading the images and interrupt the page reproduction… for example skype contact icons etc.
    Only after finishing that html stuff from / the site begins to load the images… after more than 30 sec.

    Seen with firefox dev tools (shift + f5)
    Meantime helped me with WP fastest cache…

    leberwurst79, were you able to make the onedrive images load faster with WP fastest cache? If so how much faster? It seems I can’t use it with WordPress multisite, but it may be something to look into, with another caching plugin.

    I found a somewhat okay solution with client side caching, but the user would have to load the gallery pages once before it becomes faster. The best solution would be server side caching, which I’m unsure how to implement. If anyone can point me in the right direction, that’d be great. Thanks in advance.

    I used this script to substitute admin-ajax.php basically, and edited the Perfect OneDrive plugin to use my own ajax.php rather than admin-ajax.php. I put it in the root directory of my website.

    <?php
    //mimic the actual admin-ajax
    define('DOING_AJAX', true);
    
    if (!isset( $_REQUEST['action']))
        die('-1');
    
    //make sure you update this line
    //to the relative location of the wp-load.php
    require_once( dirname( __FILE__ ) . '/wp-load.php' );
    
    //Typical headers
    header('Content-Type: text/html');
    send_nosniff_header();
    
    //Enable caching
    $expires = 60 * 999999999999999999999999999999999999999;
    header('Pragma: public');
    header('Cache-Control: maxage=' . $expires);
    header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
    
    $action = esc_attr(trim($_REQUEST['action']));
    
    //A bit of security
    $allowed_actions = array(
        'pweb_onedrive_download_file',
        'pweb_onedrive_display_photo'
    );
    if(in_array($action, $allowed_actions)){
        if(is_user_logged_in()) {
            do_action('wp_ajax_'.$action);
        }
        else {
            do_action('wp_ajax_nopriv_'.$action);
        }
    }
    else {
        die('-1');
    }

    In case you’re interested here’s the working code for server side caching. You may change the cache_file path. Also, you will need to comment out the die() in a few places inside the plugin file pwebonedrive.php

    Create an ajax.php file with this code in it. You will need to change pwebonedrive.php to point here instead of the admin-ajax.php file.

    <?php
    $imageID = $_REQUEST['code'];
    $cache_file = $_SERVER['DOCUMENT_ROOT']."/images/portfolio-cache/$imageID.jpg";
    $contents = "";
    if (file_exists($cache_file)) {
    	header('Content-Type: image/jpeg');
    	echo file_get_contents($cache_file);
    }
    else {
     	// Cache does not exist or force a cache
    	// Dynamically load the data and display it
    		//mimic the actual admin-ajax
    	define('DOING_AJAX', true);
    
    	if (!isset( $_REQUEST['action']))
    		die('not working');
    
    	//make sure you update this line
    	//to the relative location of the wp-load.php
    	require_once( dirname( __FILE__ ) . '/wp-load.php' );
    
    	//Typical headers
    	$action = esc_attr(trim($_REQUEST['action']));
    
    	//A bit of security
    	$allowed_actions = array(
    		'pweb_onedrive_download_file',
    		'pweb_onedrive_display_photo'
    	);
    	if(in_array($action, $allowed_actions)){
    		if(is_user_logged_in()) {
    			ob_start();
    			do_action( 'wp_ajax_'.$action );
                $contents = ob_get_contents();
               	ob_clean();
    		}
    		else {
    			ob_start();
    			do_action( 'wp_ajax_nopriv_'.$action );
                $contents = ob_get_contents();
                ob_clean();
    		}
    	}
    	else {
    		die('not working again');
    	}
    	// Save session data
    	$session_data = $contents; // Get the session data
    	$filehandle = fopen($cache_file, 'w+') or die("can't open file"); 
    
    	// open a file write session data
    	fwrite ($filehandle, $session_data);
    	// write the session data to file
    	fclose ($filehandle);
    }

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘performance issue’ is closed to new replies.