Satya Prakash
Satya Prakash

Reputation: 3502

How to Reduce 'Waiting Time' and 'Receiving Time' on Page Load

I am using CloudFront and many time I see Wait Time and Receiving Time is too high.

According to Firebug document, Waiting time and Receiving time means:

Waiting - Waiting for a response from the server

Receiving - / (from cache) Time required to read the entire response from the server (and/or time required to read from cache)

I do not understand why it takes so much time and what I can do to reduce the time?

enter image description here

Upvotes: 11

Views: 28806

Answers (2)

Sebastian Zartner
Sebastian Zartner

Reputation: 20125

Waiting

This means that the browser is waiting for the server to process the request and return the response.

When that time is long, it normally means your server-side script takes long to process the request.

There are many reasons why a server-side script may be slow, e.g. a long-running database query, processing of a huge file, deep recursions, etc.

To fix that, you need to optimize your script. Besides optimizing the code itself, a simple way to reduce the execution time for subsequent requests is to implement some kind of server-side caching.

Receiving

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

When that time is long, it either means your network connection is slow or the received data is (too) big.

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

Reducing the response size can be done by compressing the transferred data e.g. by enabling gzip and/or removing unnecessary characters like spaces from the output before outputting the data. For HTML responses, try to reduce the size of the HTML structures. You may also choose a different format for the returned data, where possible, e.g. use JSON instead of XML for data or directly returning HTML.

Generally

To generally reduce the waiting and receiving times you may implement some client-side caching, e.g. by setting appropriate HTTP headers like Expires, Cache-Control, etc. Then the browser will only make rather small requests to check whether there are new versions of the data to fetch.

You can also avoid the requests completely by saving the data on the client side (e.g. by putting it into the local or session storage) instead of fetching it from the server every time you need it.

Upvotes: 6

Litmus
Litmus

Reputation: 10996

There are multiple things you can do.

  1. Set appropriate headers Expires, Cache-control, ETag etc.
  2. Use gzipped versions of the assets
  3. User Sprites where possible. Merge your CSS files into one, merge your JS files into one

Run your site through WebpageTest.org and go through all the recommendations.

Run your site through YSlow and go through all the recommendations

Upvotes: 6

Related Questions