Sign in Registration
ruen

Why does the site take a long time to load on the first visit and between interruptions of page requests

There are times when a site is developed on local hosting and is ready to be transferred to a working hosting, however, on a working hosting, delays in opening pages are visible (the site takes a long time to load) that were not on local hosting. Moreover, such delays are of a variable nature - there are delays during the first visit and after breaks between page requests. What is the reason and how to fix this problem?

site-low-first-database-cache

The answer to a question can take time even for experienced professionals. Usually, you have to perform a lot of testing operations and study all kinds of site logs to find an answer, but this may not help either. After all, delays began to appear only on a working hosting, and on a local one - everything works quickly.

I must say that there can be many reasons, but the most likely one is poor optimization of database queries or its absence. Such requests generate the transfer of large amounts of data between the site and the database, especially if they are located on different servers. Moreover, both the requests themselves and the amount of processed data slow down the speed.

But why such delays are not visible on local hosting ? Local hosting does not transfer data over the network, so even unoptimized queries and fetching large amounts of data may not greatly affect the speed of opening site pages. The same cannot be said about a website hosted on a network on a working hosting.

Technical explanation - at the first request or with some waiting between requests (for example, 20 seconds), the process responsible for working with the database is re-created - the old process is destroyed and the cache is flushed. If you make requests with a shorter interval, the process does not have time to be destroyed and returns data more quickly, since it has already been created and has all or part of the cached data that needs to be returned.

How to eliminate the delays when opening the site for the first time described above? You need optimize code, responsible for queries to the database. For example, set limits on the number of selected rows from it on each request. Finding slow queries is easy - for example, in the code, you can set in certain places to insert the time code to record the speed and thus search for a slow section of the code. When it is found - perform optimization, and if it is useless - then you can resort to using the cache . It is quite easy to create your own caching system on the site, but that is beyond the scope of this article.

Comments (0)
For commenting sign in or register.

Latest articles

Popular sections

Eqsash (Tools)

Android app - VK LAST USER ID, отучитель от зависимости и т.д.:
Available on Google Play

Amessage (Communication)

Login to the web version
Android app:
Available on Google Play

Share this

Subscribe to

YouTube

Books

IT notes - In simple language about the most necessary things (HTML, CSS, JavaScript, PHP, databases, Drupal, Bitrix, SEO, domains, security and more), PDF, 500 p.