Codeigniter 网站加载某些页面大约需要 30 秒
我有一个 codeigniter 网站,可以在 localhost 上完美运行,但现在我已将其移至 Host gator,如果加载的话,一些页面请求大约需要 30 秒才能提供!奇怪的是,这似乎是随机的,在等待页面加载时,如果我只需重新单击链接,页面就会正常加载。我不确定这是否是我的控制器中的编程问题(下面的代码)或只是主机鳄鱼端的问题。请有人帮助我,因为我快疯了。
<?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 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');
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议您使用 codeigniter profiler 进行测试,它将显示所有处理时间,例如 sql 执行等...
启用后,将生成一个报告并将其插入到页面底部。
要禁用您将使用的探查器:
有关更多详细信息 http://codeigniter.com/user_guide/libraries/ output.html
希望这会对您有所帮助,如果有任何问题请告诉我们...谢谢!
I suggest you to test with codeigniter profiler, It will show all the processing time like sql execution etc...
When enabled a report will be generated and inserted at the bottom of your pages.
To disable the profiler you will use:
For more details http://codeigniter.com/user_guide/libraries/output.html
Hope this will help you, let us know if anything there... Thanks!!
您的网站上有 Javascript 或外部文件吗?这可能就是问题所在。
尝试使用 Firebug/YSlow,您可能会发现外部 js/文件(例如 Facebook 或 Twitter js)是否需要花费大量时间来加载。
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.