How can I reduce the time of matomo.js?


This is an example of a page from one of my sites.
The highlighted one is matomo.js.

How can I reduce this time?

I added this .htaccess file to the matomo folder, but it doesn’t seem to have changed much … :pensive:

#compressione gzip
<IfModule mod_deflate.c>
      <IfModule mod_setenvif.c>
            BrowserMatch ^Mozilla/4 gzip-only-text/html
            BrowserMatch ^Mozilla/4\.0[678] no-gzip
            BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
            BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
      </IfModule>
      <IfModule mod_headers.c>
            Header append Vary User-Agent env=!dont-vary
            <FilesMatch ".(js|css|xml|gz|html)$">
                Header append Vary: Accept-Encoding
            </FilesMatch>
      </IfModule>
AddOutputFilterByType DEFLATE text/plain text/html text/css application/javascript application/x-javascript text/javascript text/richtext image/svg+xml text/xsd text/xsl text/xml image/x-icon
</IfModule>


#cache
<ifModule mod_headers.c>
	#Keep Alive
	Header set Connection keep-alive
   # 1 mese
   <FilesMatch ".(js|css|swf)$">
     Header set Cache-Control "max-age=2628000, public"
   </FilesMatch>
  </ifModule>

# Caching -- mod_expires
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/x-icon "now plus 1 year"
    ExpiresByType application/pdf "now plus 1 year"
    ExpiresByType image/gif "now plus 1 year"
    ExpiresByType image/png "now plus 1 year"
    ExpiresByType image/jpg "now plus 1 year"
    ExpiresByType image/jpeg "now plus 1 year"
    ExpiresByType text/css "now plus 1 month"
    ExpiresByType application/javascript "now plus 1 month"
    ExpiresByType application/x-javascript "now plus 1 month"
    <FilesMatch "\.(pl|cgi|spl|scgi|fcgi)$">
    ExpiresActive Off
    </FilesMatch>
</IfModule>

Google seems to give increasing importance to download times, so it may be nice to reduce it as much as possible.

Hi,

piwik.js is just a file served by your webserver just like every other .js file.

I don’t know what the colors in your image mean, but I am going to guess that the long orange part of it is DNS resolution. Maybe for whatever reason the DNS server used to resolve your domain is really slow. If this is the case you could (apart from trying to find out why) take a look at dns prefetch. This allows the browser to already resolve the domain much earlier, long before it comes across the piwik.js

But this is just assuming DNS is in fact the slow part of the request.

Umh… :thinking: not sure is the dns…
https://ibb.co/tHzk6B3

I also try to add dns-prefetch to one of my sites, isn’t changed too much… praticallly nothing…

matomo is on the same server, but in a subdomain of one of my sites, so I can access to it from all my sites.

The server is a vultr vps, the domain is register in namesilo… can it be fault of one of them?

I was thinking now :thinking:
that in all my sites I have a shared folder, with a symlink (two folders actually, it depends on the site and its structure) but… Could I use it in some way to point to matomo.js or matomo.php without using the subdomain?
Continuing to use the subdomain to access matomo…

Hi,

So it isn’t DNS. Honestly I am running out of ideas (and to be fair I never had an issue with static files being served slowly with any webserver).

For comparison this is on matomo.org:
grafik

This is on one of my sites (first pageload, so dns isn’t resolved yet):
grafik

Agree wheth you :thinking: not sure is the dns