We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30879
    • 40 Posts
    Hi peeps, hoping someone can help out.

    I have a snippet named installatron. and call it with [!installatron!]

    the snitppet contains

    <?php
    $data = file('http://au1.netgss.com/optic');
    
      natcasesort($data);
    
      foreach($data as $element)
      {
        $element = trim($element);
        $pieces = explode("|", $element);
        $output = "<table width=\"570\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"brdrdashed\">";
        $output .= "<tr>";
        $output .= "<td width=\"358\" valign=\"top\"><h2>{$pieces[0]}</h2>";
        $output .= $pieces[12];
        $output .= "<br><br><strong>From the Author</strong><br>{$pieces[13]}</td>";
        $output .= "<td width=\"212\" valign=\"top\"><img src=\"http://installatron.com/script_images/{$pieces[10]}_button.gif\"><br>";
        $output .= "Script: <strong>{$pieces[0]}</strong><br>";
        $output .= "Website: <a href=\"{$pieces[1]}\" target=\"_blank\">{$pieces[0]}</a><br>";
        $output .= "Version: <strong>{$pieces[2]}</strong><br>";
        $output .= "Type: <strong>{$pieces[3]}</strong><br>";
        $output .= "Category: <strong>{$pieces[4]}</strong><br>";
        $output .= "Installer ID: <strong>{$pieces[10]}</strong><br></td>";
        $output .= "</tr></table><br>";
        echo $output;
      }
      
      $start = microtime();
    for ($i = 0; $i < 10000; ++$i)
            $n = getdate(time());
    $end = microtime();
    list($s0, $s1) = explode(' ', $start);
    list($e0, $e1) = explode(' ', $end);
    echo sprintf('<hr>This page took %.2f seconds to generate',
    ($e0+$e1)-($s0+$s1));
    ?>


    it takes about a minute or so to display. if i remove the <img src=\"http://installatron.com/script_images/{$pieces[10]}_button.gif\"> call to the remotely hosted image it works instantly.

    Ive tried disabling cache on snippet and on the doc. to no avail.

    If i load the whole php code outside of modx it loads perfectly quick. but as soon as modx trys to get involved it takes about a minute to spit out the rendered page.



      • 10487 MODX Staff
      • 1,535 Posts
      No problems from my end - tried the snippet locally and it executes in 0.12s. I think your problem may not be directly related to the snippet ... what exactly I don’t know, without knowing more about your hosting environment and MODx setup.

        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 30879
        • 40 Posts
        Quote from: garryn at Jul 18, 2009, 09:53 PM

        No problems from my end - tried the snippet locally and it executes in 0.12s. I think your problem may not be directly related to the snippet ... what exactly I don’t know, without knowing more about your hosting environment and MODx setup.



        hmm a couple of things,

        If i just pop the snippet code in its own php file, and execute it loads instantly.
        The page in modx itself shows. MySQL: 0.0098 s, 21 request(s), PHP: 0.3532 s, total: 0.3631 s, document retrieved from database
        which is quick.

        its as if the rendering of the page through modx is causing the delay. and its only when i have the image tag inserted in modx it loads slow.



        what other info would you need ot be able to assist mate smiley
          • 10487 MODX Staff
          • 1,535 Posts
          Helpful info to provide: http://modxcms.com/forums/index.php/topic,489.0.html

          MODx isn’t going to affect how the image is loaded in the browser; all MODx does is churn out the PHP-rendered output to the browser. In that sense, the problem is not directly MODx related in my opinion. What happens if you clear your browser cache and then try and run the code as a standalone PHP file? (Just curious if browser caching is having an effect on timings)
            Garry Nutting
            Senior Developer
            MODX, LLC

            Email: [email protected]
            Twitter: @garryn
            Web: modx.com
            • 30879
            • 40 Posts
            Quote from: garryn at Jul 18, 2009, 10:15 PM

            Helpful info to provide: http://modxcms.com/forums/index.php/topic,489.0.html

            MODx isn’t going to affect how the image is loaded in the browser; all MODx does is churn out the PHP-rendered output to the browser. In that sense, the problem is not directly MODx related in my opinion. What happens if you clear your browser cache and then try and run the code as a standalone PHP file? (Just curious if browser caching is having an effect on timings)

            If i run the code in a standalone file with my css attached., it loads quickly, perfectly. - this indicates the hosting environment isnt an issue, or css style.

            ive even viewed the source of the page that finally is output, copied the source pasted it into a standalone php file uploaded it and it rendered really quick.

            The dirty way, is for me just to popup the standalone file i guess.

            but it seems to be someway that modx is handling that image tag ><
              • 30879
              • 40 Posts
              hmm if i reference locally hosted images, its instantly returned.

              as soon as i change back to remotely hosted - it takes ages (eventually showing up)

              If i view source and put it in its own standalone doc, it works instantly, and if i put the code generation in a standalone file it works fine, but as soon as i run it through modx (with all caching disabled, its a 1 min wait.. hmmm