PHP tracking first page reload is slow

As originally reported here: https://github.com/matomo-org/matomo-php-tracker/issues/88

I have noticed that on the first page reload of the day (website currently has no visitors) the website loading is slow. This is caused by the php tracker. Possible reasons:

  • DNS resoltion
  • Matomo instance is in idle mode

I am using the Matomo PHP tracker, not the javascript code:

Could you give me a hint why this happens? What would be the best idea to fix this? I thought about using an async call, however I am not very familiar with async code on php.