How to configure CDN access for Magento 2
Article Number: 1284 | Rating: Unrated | Last Updated: Thu, Jul 20, 2017 at 10:50 AM
How to configure CDN access for Magento 2
This article explains how Nexcess clients can use the Client Portal to configure their CDN service for use with their Magento 2 store.
Table of contents
An active CDN service with Nexcess. To order a Nexcess service plan, visit our website.
A functioning Magento store on your Nexcess server.
Your Client Portal username and password. These were originally provided in the Nexcess Welcome Email, though you may have since changed them. If you cannot locate this information, click the Reset Password link on the Client Portal login menu or contact the Nexcess Support Team.
Exception about media assets
Certain types of content, such as images, video, and audio media assets like JPG, MP3, MP4, and so on, are already compressed. Additional compression to these types of assets will not significantly diminish file size. Therefore, it is recommended you do not enable compression for these asset types.
To learn how to configure CDN access for Magento 1.x, see How to configure CDN access for Magento.
This procedure consists of 7 sections:
- Access the CDN control panel
- Configure large HTTP delivery
- Configure small HTTP delivery
- Verify settings
- Update your Magento 2 installation
- Purge the CDN cache
- Activate CDN compression
1: Access the CDN control panel
If you have not already done so, purchase a Nexcess CDN plan or use a Magento hosting plan that comes with CDN access. If you plan already includes a CDN but you do not see one listed, contact the Nexcess Support Team for assistance.
Log in to the Client Portal. From the dashboard, click Service > Other (Figure 1).
Figure 1. Client Portal dashboard: Service > Other.
Locate the relevant CDN service. From the menu toggle, followed by CDN Control Panel (Figure 2).
Figure 2. Menu toggle and CDN Control Panel selection.
Choose your preferred language from the pop-up menu.
2: Configure large HTTP delivery
Attention: You must enable CDN compression as instructed below for both the HTTP large and HTTP small delivery methods to fully utilize the CDN’s compression utility.
Select HTTP Large > Customer Origin (Figure 4).
Figure 4. HTTP Large > Customer Origin.
In the Directory Name field, enter your preferred name, such as “magento.” (Figure 5).
In the Hostname or IP Address field, type the web address (URL) of your store; for example, store.nexcess.net (Figure 5).
Figure 5. HTTP Large Object Customer Origins example data.
Near the Hostname or IP Address field, click Add (Figure 6)
Figure 6. Add button in HTTP Large Object Customer Origin control panel.
On the lower right in the HTTP Large Object Customer Origins control panel, click Add (Figure 7).
Figure 7. Second Add button after adding your store URL.
Setup for your large HTTP delivery is now complete (Figure 8). Proceed to the “Configure small HTTP delivery” section.
Figure 8. Completion of large HTTP delivery setup.
3: Configure small HTTP delivery
Select HTTP Small > Customer Origin (Figure 9).
Figure 9. HTTP Small > Customer Origin.
In the Directory Name field, enter your preferred name, such as “magento” (Figure 10).
In the Hostname or IP Address field, type the URL of your store; for example, store.nexcess.net (Figure 10).
Figure 10. HTTP Small Object Customer Origins example data.
Near the Hostname or IP Address field, click Add (Figure 11).
Figure 11. Add button in HTTP Small Object Customer Origin control panel.
On the lower right in the HTTP Small Object Customer Origins control panel, click Add (Figure 12).
Figure 12. Second Add button after adding your store URL.
Setup for your small HTTP delivery is now complete (Figure 13). After waiting about one hour to give the CDN service time to cache your data, proceed to the “Verify settings” section.
Figure 13. Completion of small HTTP delivery setup.
4: Verify settings
Attention: Allow the CDN service at least one hour to cache your data before you attempt to verify the new settings as outlined below.
To verify both large and small customer origins, use the URLs provided in the Customer Origin panel and append destinations specific to Magento:
To test the small HTTP customer origin:
Locate your store’s URL in the HTTP Small Object Customer Origins control panel (Figure 14).
Figure 14. HTTP Small > Customer Origin and example small origin URL.
Append /js/mage/cookies.js to your store’s URL. From the example URL shown in Figure 14, the appended URL would read: http://smhttp.42588.nexcesscdn.net/8016fc0/magento/js/mage/cookies.js
Enter the appended URL into your web browser. If the page loads, your assets have successfully propagated to the CDN and you may proceed to Step 2. If you have already completed Step 2, proceed to the next section.
To test the large HTTP customer origin, repeat Step 1 from the HTTP Large Object Customer Origins Panel (Figure 15).
Figure 15. HTTP Large control panel selection.
5: Update your Magento 2 installation
- Update your Magento install to use the new large and small origin URLs by selecting Stores > Configuration > Web (Figure 16).
Figure 16. Magento Admin Panel; Stores > Configuration.
- From the General tab, select Web (Figure 17).
Figure 17. General tab; Web selection.
- From the Store View drop-down list, select your desired store (Figure 18).
Figure 18. Store View drop-down list.
- In the Base URL (Secure) section, in the Base URL for Static View Files field, enter the small origin URL you created in the “Configure small HTTP delivery” section, Step 6 (Figure 19).
Figure 19. Base URL (Secure) section; Base URL for Static View Files and Base URL for User Media Files fields.
- In the same section, in the Base URL for User Media Files field, enter large origin URL you created in the “Configure large HTTP delivery” section, Step 6 (Figure 19).
- Flush the Magento 2 cache:
- From the main menu, select System > Cache Management (Figure 20).
Figure 20. Magento admin panel; System > Cache Management.
- On the upper right, click Flush Magento Cache (Figure 21).
Figure 21. Cache Management; Flush Magento Cache button.
6: Purge the CDN cache
Follow the procedure given in How to purge the CDN cache.
7: Activate CDN compression
Follow the procedure provided in How to activate CDN compression.
For 24-hour assistance any day of the year, contact our Support Team by email or through the Client Portal.
There are no attachments for this article.