【问题标题】:High latency in codeigniter project on localhost本地主机上的 codeigniter 项目中的高延迟
【发布时间】:2017-06-20 07:52:21
【问题描述】:

这个问题以前在这里被问过,但我找不到一个好的解决方案。 Very high latency in first HTTP request on CodeIgniter project

第一个请求(文档请求)需要很长时间(大约一分钟)。我不知道问题是什么,也不知道要在此处粘贴什么代码,以便更容易找到错误。此问题是项目特定的,不会发生在其他项目中。我已经尝试了很多,但找不到解决方案。请让我知道我应该提供什么以便解决问题。提前致谢。 Please find the screenshot of the request timelist here

【问题讨论】:

    标签: php codeigniter


    【解决方案1】:

    在 httpd.conf 中设置 ServerName 属性修复了延迟(最坏的情况下最多可达 10 秒)

    # ServerName gives the name and port that the server uses to identify itself.
    # This can often be determined automatically, but we recommend you specify
    # it explicitly to prevent problems during startup.
    #
    # If your host doesn't have a registered DNS name, enter its IP address here.
    ServerName 127.0.0.1:80
    

    还要检查 /etc/hosts 是否正确?

    # localhost name resolution is handled within DNS itself.
    #   127.0.0.1       localhost
    #   ::1             localhost
    

    这会很有帮助。

    【讨论】:

    • 只有这个特定的 codeigniter 项目不起作用。其他项目正在运行,这意味着这与 httpd.conf 和 /etc/hosts 文件无关。我说的对吗?
    • 是的,如果其他人工作正常,那么在 codeigniter 设置中会有一些问题。你在 CI 中使用过缓存吗?您可以在登录功能中添加以下提到的行并检查。 $this->output->cache(1);
    • 是的,我在 CI 中使用了缓存。现在,它显示“尝试加载资源时发生错误。”
    • 我已经分享过了。请看一下,让我知道解决方案。非常感谢。
    • 请你分享这个login_check()language_setting()函数。?
    【解决方案2】:

    好的,我终于找到了答案。我的 CI 应用程序无法查询数据库。加上我的 constants.php 文件指向 prod 数据库。我将 constants.php 更改为指向 localhost 并更改 database.php 以适应本地数据库。

    【讨论】:

      猜你喜欢
      • 2014-09-27
      • 2019-08-14
      • 2014-11-03
      • 1970-01-01
      • 2018-07-04
      • 1970-01-01
      • 1970-01-01
      • 2015-08-08
      • 2020-08-22
      相关资源
      最近更新 更多