matomo and my website are installed on the SAME server but still very slow
how do I speed this up?
Are all requests that slow?
If you have browser archiving enabled in Matomo, some of the tracking request might trigger an archiving process, which let the requests run a bit longer.
If you want to avoid that, you can disable browser archiving and set up an archiving cron. See https://matomo.org/docs/setup-auto-archiving/
Also note, that it does not matter on what server the sites are running, as each request is made from the users browser and it is therefore irrelevant (mostly) where the server is.
why is matomo calling two files? piwik.js and piwik.php
calling just one file ( piwik.js) would be better
If you are able to provide a solution to transfer data from the users
browser to Matomo without sending a request, we would for sure implement
it. But even a Rest API requires a request...
additional request maybe have a look at the PHP Tracker or Log Analytics.
this takes too long to load the page
Did you setup cron archiving as suggested in https://github.com/matomo-org/matomo/issues/13152#issuecomment-403408157?
There is nothing special about your call, it's a generic page view.
You may also just get a better server and find the request time very fast. Or install queued tracking, there it takes like 5ms. https://plugins.matomo.org/QueuedTracking