CDN for Magento 2

CDN for Magento 2

Ideal scenario for a website built on Magento 2 platform is to use CDN or content delivery network to serve page assets such as JavaScript, CSS, Fonts, HTML and finally Media to a client's browser.

A content delivery network (CDN) is a system of distributed servers (network) that deliver webpages and other Web content to a user based on the geographic locations of the user, the origin of the webpage and a content delivery server.

This service is effective in speeding the delivery of content of websites with high traffic and websites that have global reach. The closer the CDN server is to the user geographically, the faster the content will be delivered to the user. CDNs also provide protection from large surges in traffic.

For Magento 2 website to be able to serve media (image files including Product Images, CMS WYSIWYG stored under magento/pub/media/ directory) from a CDN server few changes should be done. As per my experience setting up CDN server there is a minimum set of actions should be done.

.htaccess file Update the magento/pub/media/.htaccess file and set additional Header for allowing CORS processes images. There are good few scenarios in Magento 2 where images are requested via XmlHttpRequest.

Apache Header Module Enable additional Header module for Apache server. This will allow to read and process additional CORS header set in the .htaccess file.

CNAME Additional CNAME or domain name might be created, something like cdn.mywebsite.com to have custom domain for all your media assets stored under CDN.

At most important is to configure actual CDN server. Here you may select server depending on your expectations and resources available.

Question of the Week

What do you want to see more or less in this weekly newsletter? Are there anything you would like to share or provide feedback?

This would mean a lot to me to hear your thoughts.

Send your replies to blog@maxpronko.com

magento 2 apache cdn cache

Related Articles

Comments

Next Article Previous Article

LinkedIn Twitter Facebook