为什么在访问页面时会多次调用Magento 2 index.php文件? 您所在的位置:网站首页 网页脚本文件 为什么在访问页面时会多次调用Magento 2 index.php文件?

为什么在访问页面时会多次调用Magento 2 index.php文件?

2023-06-30 09:20| 来源: 网络整理| 查看: 265

我正在试图找出Magento 2运行缓慢的原因,我已经用xdebug_disable()禁用了XDEBUG,当我意识到index.php脚本多次被调用时,我正试图对执行时间进行划分。

我使用microtime()来管理index.php脚本的执行时间,并将输出记录到一个文件中,当访问搜索页面时,它会被打印两次,例如:

define('DEBUG_START', microtime(true)); // At the very top of index.php ... // content of index.php ... file_put_contents(DEBUG_FILE, 'Execution time: ' . (microtime(true) - DEBUG_START) . PHP_EOL, FILE_APPEND | LOCK_EX); // At the very end of index.php

调试文件中的结果输出为(对于搜索页https://dev/catalogsearch/result/?q=test):

Execution time: 3.8935000896454 Execution time: 2.0475149154663

它似乎在产品页面(https://dev/test-product.html)上被调用了3次:

Execution time: 0.62609481811523 Execution time: 0.1364049911499 Execution time: 1.5069890022278

知道为什么吗?

更新:

我尝试过不同版本的Magento (2.2.x和2.3)以及PHP7.0和7.2的类似结果.



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有