为什么Codeigniter项目在线加载速度慢?

时间:2016-04-28 11:01:18

标签: codeigniter lazy-loading

我的codeigniter项目加载在线浏览器

非常慢

但是在localhost上快速

我的项目就像一个媒体页面.. 它有谷歌登录。只需注册登录和上传帖子,youtube网址上传..

这是我的主页控制器

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

class UserList extends CI_Controller
{
public function __construct()
{
    parent::__construct();
    $this->load->helper(array('form', 'url'));
    $this->load->library('form_validation');
    $this->load->library('security');
    $this->load->library('tank_auth');
    $this->lang->load('tank_auth');
    // load database
    $this->load->database();
    // Load session library
    $this->load->library('session');
    echo $username = $this->input->get('username'); 
}

function index()
{
    if ($this->tank_auth->is_logged_in())   
    {
        $data['login_status'] = $this->tank_auth->is_logged_in();
        $data['userId'] = $this->tank_auth->get_user_id();
        $data['username'] = $this->tank_auth->get_username();
        $id = $this->tank_auth->get_user_id();
        $data['firstname'] = $this->tank_auth->get_firstname();
        $data['lastname'] = $this->tank_auth->get_lastname();
        $data['image'] = $this->tank_auth->get_image();
        //$data['gender'] = $this->tank_auth->get_gender();
        $data['userList'] = $this->db->or_not_like('id',$id)->get('users')->result();
        //$data['followers'] = $this->db->where('follower_id',$id)->get('users')->result();

        $pagename =  $this->db->where('id',$id)->get('users')->result();
        $data['loginuserpage'] = $pagename[0]->pagename;
        $this->load->view('header/login',$data);
        $this->load->view('pages/users',$data);
        $this->load->view('footer/footer');

    }
    else {
        $data['login_status'] = 0;
        $data['userList'] = $this->db->get('users')->result();
        $this->load->view('header/withoutLogin',$data);
        $this->load->view('pages/users',$data);
        $this->load->view('footer/footer');
        //redirect('/auth/login/');
    }
  }

我正在使用所有函数和页面中的条件

但仍然没有开始上传,现在本身就是非常慢的

我不知道问题出在哪里?..

请帮助我?。

先谢谢, 的 Shruthi。

1 个答案:

答案 0 :(得分:2)

首先,请打开调试以查看查询时间。在核心控制器(如果存在)或任何控制器中添加此代码:

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

现在,您可以在网页下查看查询时间。顺便说一句,我认为你的问题不是PHP而是HTML。可能你的HTML加载缓慢。如果您可以添加示例视图文件,我将确定这一点。

如果你的问题是前端(例如HTML,CSS,JS),你可以缩小它们。您也可以停止在HTML中包含不必要的文件。

编辑:如果您没有任何视图,可能是您对此Google内容有授权错误。它可以使事情变得缓慢。

相关问题