开发者

Codeigniter website taking ~30 seconds to load some pages

开发者 https://www.devze.com 2023-03-14 21:54 出处:网络
I have a codeigni开发者_如何转开发ter website that runs beautifully on localhost, but now that I have moved it to Host gator some page requests are taking around 30 seconds to serve up, if loaded at a

I have a codeigni开发者_如何转开发ter website that runs beautifully on localhost, but now that I have moved it to Host gator some page requests are taking around 30 seconds to serve up, if loaded at all! The weird thing is that is seemingly random, and while waiting for the page to load, if I simply re-click the link the page will load normally. I'm not sure if this is a programming problem in my controllers (code below) or just issues on host gators end. Please plesse please someone help me out here, as I am going insane.

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Company extends CI_Controller
{
function __construct()
{
    parent::__construct();

    if (!$this->session->userdata('language')) $this->session-    >set_userdata('language', 'en');
}

function index ()
{
    $tags['title'] = 'title tag';

    $this->load->view($this->session->userdata('language').'/includes/view_header',$tags);
    $this->load->view($this->session->userdata('language').'/company/view_company');
    $this->load->view($this->session->userdata('language').'/includes/view_footer');    
}

function warranty ()
{
    $tags['title'] = 'title tag';

    $this->load->view($this->session->userdata('language').'/includes/view_header',$tags);
    $this->load->view($this->session->userdata('language').'/company/view_warranty');
    $this->load->view($this->session->userdata('language').'/includes/view_footer');        
}
}


I suggest you to test with codeigniter profiler, It will show all the processing time like sql execution etc...

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Company extends CI_Controller
{
    function __construct()
    {
        parent::__construct();
        $this->output->enable_profiler(TRUE);
        if (!$this->session->userdata('language')) $this->session-    >set_userdata('language', 'en');
    }

When enabled a report will be generated and inserted at the bottom of your pages.

To disable the profiler you will use:

$this->output->enable_profiler(FALSE);

For more details http://codeigniter.com/user_guide/libraries/output.html

Hope this will help you, let us know if anything there... Thanks!!


Do you have any Javascript or external file on your site? That might be the problem.

Try using Firebug/YSlow and you'll probably get if an external js/file (Facebook or Twitter js for example) is taking lot of time to load.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号