简体   繁体   English

如何使用Drupal更快地加载Motomo?

[英]How to load Motomo faster with Drupal?

I have a site with Drupal 8 我有一个Drupal 8网站

I also have another second server with another domain name for Matomo audience analysis. 我还有另一台服务器,该服务器具有用于Matomo受众分析的另一个域名。

My Drupal 8 site is slow to load. 我的Drupal 8网站加载缓慢。 How does the following advice apply with Drupal 8 ? 以下建议在Drupal 8中如何应用? It is a LAMP server. 这是一个LAMP服务器。

Preload DNS Often a Matomo (Piwik) is hosted on a different domain and when the browser loads the JavaScript tracker file, it needs to first perform a DNS lookup to find the IP address for this domain. 预装DNS通常,Matomo(Piwik)托管在其他域中,并且当浏览器加载JavaScript跟踪器文件时,它首先需要执行DNS查找以查找该域的IP地址。 By adding the below snipped for your Matomo domain, it can boost the performance of loading the tracker file by 10ms to 50ms. 通过为您的Matomo域添加以下内容,它可以将跟踪文件的加载性能提高10毫秒到50毫秒。

 <link rel="dns-prefetch" href="//example.innocraft.cloud"> 

enter image description here 在此处输入图片说明

You can try adding a dns-prefetch and it should work and speed up the DNS query a bit (but keep in mind that this is only a tiny fraction of the 1.8s). 您可以尝试添加dns-prefetch,它应该可以工作并可以稍微加快DNS查询的速度(但请注意,这只是1.8秒的一小部分)。

For this just add the HTML tag as high up in the HTML of the site as possible (so somewhere in the <head> ) 为此,只需将HTML标记尽可能高地添加到网站的HTML中(所以<head>中的某个位置)

<link rel="dns-prefetch" href="http://analytics.yourdomain.example">

Also keep in mind that while your Matomo loads quite slow, this shouldn't slow down your website as Matomo only inizialises after the page has finished loading and is usable by the visitor. 另外请记住,尽管Matomo的加载速度非常慢,但这不会减慢您的网站的速度,因为Matomo仅在页面加载完成并可供访问者使用后才会初始化。 (so the green and blue lines in you image) (因此图像中的绿色和蓝色线条)

You can look at https://matomo.org/docs/optimize-how-to/ for more tips on how to optimize Matomo to be faster. 您可以查看https://matomo.org/docs/optimize-how-to/,以获得有关如何优化Matomo使其更快的更多提示。 (eg a newer PHP version, a SSD for the database, more RAM for the database, enabling opcache, etc.) (例如,较新的PHP版本,用于数据库的SSD,用于数据库的更多RAM,启用opcache等)

You could also take a look at this plugin: https://plugins.matomo.org/QueuedTracking 您也可以看看这个插件: https : //plugins.matomo.org/QueuedTracking

It dumps the raw visitor data directly into a MySQL or Redis Table (which can bring the request down to 30ms) and then when the queue is X entries long, it asynchronously runs Matomo on everything in the queue. 它将原始访问者数据直接转储到MySQL或Redis表中(这可以将请求降低到30ms),然后当队列的长度为X个条目时,它将对队列中的所有内容异步运行Matomo。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM