Frequently Asked Question

How do I improve the performance of Magento (2.2.x)? 如何設定提升 Magento (2.2.x) 的軟件效能?
Last Updated 6 years ago

Magento has most of its functionality turned on by default, but some will not be applicable to your store, you can disable those functions to speed up your Magento website.

Especially, Magento designs the log saving in the MySQL database which consumes lots of resources (e.g. CPU load, memory, storage), this logging is completely useless and redundant because all Nethub's servers have full logging and website statistics of your website.

Enable this logging also slows down your website as well as the server, so that logging function should be turned off while you are using Magento.

To turn off the logging function in Magento:

1. Use Notepad to edit the source file of Magento.

Path : /app/code/Magento/Customer/Model/Visitor.php (If you are unable to find this file, please try /vendor/magento/module-customer/Model/Visitor.php)

2. Find

protected $skipRequestLogging = false;

3. Modify as

protected $skipRequestLogging = true;

4. Use Notepad to edit the source file of Magento.

Path : /app/code/Magento/Reports/Observer/CatalogProductViewObserver.php (If you are unable to find this file, please try /vendor/magento/module-reports/Observer/CatalogProductViewObserver.php)

5. Find

public function execute(\Magento\Framework\Event\Observer $observer)
{


6. Modify to

public function execute(\Magento\Framework\Event\Observer $observer)
{
return;


7. Upload the modified files via FTP and overwrite the original file.

If you database has already grown to big size, you can login to your MySQL database and run commands to delete log data:

TRUNCATE report_viewed_product_index;
TRUNCATE report_event;
TRUNCATE customer_visitor;

預設地 Magento 把它的大部分功能開啟了, 但有些是不適用您的商店的, 你可以停用那些功能以提升你的Magento網站.

尤其 Magento 設計時把網頁訪客存取紀錄儲存到MySQL資料庫內, 這會消耗很多的資源 (如: CPU負載, 記憶體, 硬磁容量), 這種紀錄是完全沒有用處並且是累贅的, 因為網匯在線的所有伺服器都有您的網站的完整紀錄和詳盡網站流量統計表.

啟用這種紀錄更會令你的網站和伺服器變得緩慢, 因此當你使用 Magento 時應該把紀錄功能關掉.

要關掉網頁訪客存取紀錄儲存於數據庫內的功能:

1. 使用記事本開啟 Magento 的原始檔

路徑 : /app/code/Magento/Customer/Model/Visitor.php (假如你無法找到相關檔案,你可以嘗試 /vendor/magento/module-customer/Model/Visitor.php)

2. 尋找
protected $skipRequestLogging = false;

3. 更改為
protected $skipRequestLogging = true;

4. 使用記事本開啟 Magento 的原始檔

路徑 : /app/code/Magento/Reports/Observer/CatalogProductViewObserver.php (假如你無法找到相關檔案,你可以嘗試 /vendor/magento/module-reports/Observer/CatalogProductViewObserver.php)

5. 尋找
public function execute(\Magento\Framework\Event\Observer $observer)
{


6. 更改為
public function execute(\Magento\Framework\Event\Observer $observer)
{
return;


7. 使用FTP上載經過修改的檔案到伺服器並取代原來檔案.

如果你的數據庫已增長至非常大, 你可以登入你的MySQL數據庫並執行以下指令刪除紀錄數據:

TRUNCATE report_viewed_product_index;
TRUNCATE report_event;
TRUNCATE customer_visitor;

Please Wait!

Please wait... it will take a second!