pRieStaKos Posted October 15, 2020 Share Posted October 15, 2020 (edited) Hello, I recently redesigned my template and I included hooks that returns information about service's server status (status / uptime). When a client has above 50 services (active), the page takes a lot of time to load. I tested and it takes above 60 seconds (avg) only to load the page, from any other page inside WHMCS. I checked and I know that my hooks are slowing down the page, but I need to decrease the loading time, or somehow change the page loading flow. If I could make the page loads and load the hooks after, so the visitor can see that the page is loading, but the table list takes time to fully rendered. Any suggestions ? Thank you in advance. Edited October 15, 2020 by pRieStaKos 0 Quote Link to comment Share on other sites More sharing options...
string Posted October 15, 2020 Share Posted October 15, 2020 (edited) 27 minutes ago, pRieStaKos said: Any suggestions ? I have 2 suggestions: Cache the server status, you can use the AfterCronJob hook to refresh the cache every 5 minutes. AfterCronJob is executed each 5 minutes by default. You could also create your own cronjob which is executed more often. But you should take care that the executions do not overlap. For example with a lock file or an entry in the database like "if is_running = 1, then dont execute". To get a real-time status, get the server status via an AJAX request. In that case you will also want to update your hook to not block the PHP session. curl_multi, setting reasonable timeouts and reusing the same curl handle (if you do multiple requests to the same server) can help reducing the query time. Personally I would prefer the first suggestion as it is less prone to errors. Edited October 15, 2020 by string wrong link 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.