How to configure the content delivery network (CDN) in Magento 2?
Content Delivery Network or CDN is an advanced tool that improves your website loading speed. If you have many visitors that are far from your server or if you have thousands of large files, you may need to integrate the CDN into your Magento 2. In this answer, we'll cover how to fulfill Magento CDN setup.
Say, you have a store that ships goods in 4 countries: USA, Canada, Australia, and New Zealand, but your main server is in LA. So if a customer from Australia tries to load your site, it may take a long time to load it. Why? A long distance increases latency between request to the server and its answer. Every 100 kilometers increases the response time by about 10 milliseconds. That means a client from Sydney will wait one second longer for a response from the server than a client from LA.
This can be significant for your sales because every second delay in website browsing can reduce conversions by 7%. The best CDN for Magento solves this problem. With this system, you can have copies of your content on multiple servers worldwide. As a result, your client from Sydney will be redirected to the local server, and your website will load 10 times faster.
How to set up a CDN in Magento 2
- Log in to your Admin Panel and navigate to Stores > Settings > Configuration.
- Click on the Web in the General tab. Configure 2 sections: Base URLs and Base URLs (Secure).
- Enter the CDN URLs for the Static and JavaScript (User Media) Files in the Base URLs tab.
- In the Base URLs (Secure) section, enter the same data in Secure Base URL for Static View Files and Secure Base URL for User Media Files fields.
- Save the changes.
Note: All these fields can be blank or start with the placeholder: {{unsecure_base_ url}}
How to pick the best CDN for your Magento 2
Here are some points that you need to pay attention to when choosing a CDN provider:
- How many points of presence you have and where;
- Cache and retention policy;
- Service level agreement details;
- Number of failures;
- Additional services;
- Call forwarding technology.
Besides the CDN integration, you can increase your Magento 2 loading speed reducing and optimizing the code with Google Page Speed Optimizer.
According to the statistics, you may find helpfull the following question about too many redirects error.
Login and Registration Form