Use a content delivery network
A content delivery network (CDN) can be used to store media files. Adobe Commerce on cloud infrastructure includes the Fastly CDN (see Fastly in the Commerce on Cloud Infrastructure Guide). A Commerce instance that is installed on premise does not include an integration with any specific CDN, you can use the CDN of your choice.
After configuring the CDN, you must complete the configuration from the Admin. The changes can be made at either the global or website level. When a CDN is used for media storage, all paths to media on Commerce store pages are changed to the CDN paths that are specified in the configuration.
CDN workflow
- Browser requests media - A page from the store opens in the customer’s browser, and the browser requests the media that is specified in the HTML.
- Request sent to CDN; images found and served - The request is sent first to the CDN. If the CDN has the images in storage, it serves the media files to the customer’s browser.
- Media not found, request sent to Commerce web server - If the CDN does not have the media files, the request is sent to the Commerce web server. If the media files are found in the file system, the web server sends them to the customer’s browser.
Configure a content delivery network
-
On the Admin sidebar, go to Stores > Settings > Configuration.
-
In the left panel under General, choose Web.
-
In the upper-left corner, set Store View as needed.
-
Expand the Base URLs section and do the following:
{width="600" modal="regular"}
-
Update the Base URL for Static View Files with the URL of the location on the CDN where static view files are stored.
-
Update the Base URL for User Media Files with the URL of the JavaScript files on the CDN.
Both these fields can be left blank, or can start with the placeholder:
{% raw %}{{unsecure_base_url}}{% endraw %}
-
-
Expand the Base URLs (Secure) section and do the following:
{width="600" modal="regular"}
-
Update the Secure Base URL for Static View Files with the URL of the location on the CDN where static view files are stored.
-
Update the Secure Base URL for User Media Files with the URL of the JavaScript files on the CDN.
Both these fields can be left blank, or can start with the placeholder:
{% raw %}{{unsecure_base_url}}{% endraw %}
-
-
When complete, click Save Config.