Jump to content

[ Tip ] Reduce Load Time Without Paying More


Recommended Posts

Here´s one trick to reduce dramatically the load time of a shop with Prestashop.

To achieve this we need to have access to our hosting DNS and maybe the Apache configuration file.

 

First of all, let explain how we reduce the load time. 

The web browsers have a limit in max concurrent connections (i.e. in Chrome are 6) , that is if your website have 120 elements (images, css, javascripts...) it will download in blocks of six, and will not download a new one until one connection is available. No matter if you have the fastest internet speed, your browser will download in blocks of 6. This is why in Prestashop you will find an option (Parameters>performance) called "Media Servers".  Because the limit of 6 is per Domain, so if we use another domain for images will get a download block of 12 (And we can use up to 4 domains, that is up tu 24 files per "block"). So,  let´s start!

 

Create a new registry in your main domain DNS zone. Select type CName (Canonical Name) and as subdomain set cdn, in target set your main domain. I.e. cdn.mydomain.tld > mydomain.tld

 

Step1

 

Now we need to update DNS zone and publish dns changes. Ask your hosting provider if you don´t know how to publish the changes. It can take up to 24 hours to take effect (Nowadays in about 30 minutes).

 

After this time lets test it. 

Open your logo (or any image) in a browser: i.e. mydomain.tld/img/logo.jpg

Then try your new created "CDN" cdn.mydomain.tld/img/logo.jpg

If you see the logo in the cdn subdomain go to Step 3

 

Step2

If the previous step has not worked it could be because our hosting resolves subdomains individually. So to solve this we need to add a line to our apache host configuration file. Some hosting control panels like plesk allow us to add http directives directly on web. Anyway, the line we have to add is pretty simple. 

ServerAlias "cdn.mydomain.tld"

This will tell apache server to handle requests to subdomain cdn as an access to default domain. In some cases this change will require restart the apache service. Remember this subdomain will only affect files, because if you try to acccess directly Prestashop will redirect you to the default domain configured in your shop.

Open your logo in a browser: i.e. mydomain.tld/img/logo.jpg

Then try your new created "CDN" cdn.mydomain.tld/img/logo.jpg

 

Step3

Now we have our fake CDN (read forward to know why fake). So lets add to prestashop. Go to Advanced preferences>performances and navigate to Media Servers. Add the address cdn.mydomain.tld to the first field. 

And "voilá", your shop now can download to browsers in blocks of up 12 items at the same time. Repeat all the process changing the subdomain (cnd2,cdn3...) to add more media servers.

 

Why we call it fake CDN? Because a CDN is a content delivery network. It is supposed to reduce load time in many ways. Reducing the distance from request to server, reducing time of load delegating content requests in other machines and as the last option increase the maximun concurrent connections for a customer. The 60% of websites using a CDN doesn´t really need it, because if your shop does not have more than one country (or millions of users) as target you don need a delivery network.

 

Remember. This trick will not reduce the processing time, will reduce the download time, and so on, the render time.

If you like it let me know with the "like button"

 

Have a good day!

 

Vía PrestaPresta

 

 

Edited by Prescol (see edit history)
  • Like 5
Link to comment
Share on other sites

  • 4 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...