How to reduce latency and reception time on page load

I use CloudFront, and many times I see that Wait Time and Receiving Time are too high.

According to the Firebug doc, latency and reception time means:

Waiting - Waiting for a response from the server

Getting - / (from the cache) The time it takes to read the entire response from the server (and / or the time it takes to read the cache)

I don’t understand why it takes so long and what can I do to shorten the time?

enter image description here

+6
source share
2 answers

There are a few things you can do.

  • Set the appropriate headers for Expires , Cache-control , ETag , etc.
  • Use gzip version options for Android.
  • Custom sprites where possible. Combine your CSS files into one, merge your JS files into one

Launch your site through WebpageTest.org and follow all the recommendations.

Launch your site through YSlow and follow all recommendations

+2
source

Expectation

This means that the browser expects the server to process the request and return a response.

When this time is long, this usually means that the server side of the script takes a long time to process the request.

There are many reasons why the server side of the script is slow, for example. long-term database query, huge file processing, deep recursions, etc.

To fix this, you need to optimize your script. Besides optimizing the code itself, an easy way to reduce the execution time for subsequent requests is to implement some kind of caching on the server side.

Reception

This means that the browser is receiving a response from the server.

If this time is long, it means that your network connection is slow or the received data is too large.

To reduce this time, you need to improve the network connection and / or reduce the size of the response.

Reducing the size of the response can be performed by compressing the transmitted data, for example. by including gzip and / or removing unnecessary characters, such as spaces from the output, before outputting the data. You can also choose a different format for the returned data, where possible, for example. use JSON instead of XML for data or directly return HTML.

Generally

To reduce latency and receive time, you can implement some client-side caching, for example. by setting appropriate HTTP headers such as Expires , Cache-Control , etc. Then the browser will only make small requests to check if there are new versions of the data to retrieve.

You can also completely avoid requests by storing data on the client side (for example, by storing it in local or session memory) instead of retrieving it from the server every time you need it.

+1
source

Source: https://habr.com/ru/post/955302/


All Articles