Mike Muta
Mike Muta

Reputation: 121

Codeigniter website taking ~30 seconds to load some pages

I have a codeigniter 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');        
}
}

Upvotes: 0

Views: 637

Answers (2)

juanrossi
juanrossi

Reputation: 305

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.

Upvotes: 0

Madan Sapkota
Madan Sapkota

Reputation: 26111

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!!

Upvotes: 1

Related Questions