preloder

CDN for Magento 2

Prev Next

The 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.

content delivery network (CDN) is a system of distributed servers (network) that deliver web pages 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 a 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 CORSheader set in the .htaccess file.

CNAME Additional CNAME or domain name might be created, something like cdn.mywebsite.com to have a 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.

The question of the Week

What do you want to see more or less in this weekly newsletter? Is 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

Max with his team of Magento enthusiasts won the Best Magento 1 to Magento 2 Migration Award at the Magento Imagine 2017. As CEO at Pronko Consulting, he is actively working with Magento 2, delivering superior customer experience. As one of the most famous developers on a market and in the Magento Community, he launched Magento 2 blog, Magento DevChannel – YouTube channel in 2017 where he shares his knowledge, experience and the best practices in the Magento field.

Posted on Aug 31, 2016

The Devletter

Subscribe to my Magento 2 tips and tutorials content.
Every week I send an interesting email directly to your inbox

Related Posts

Show
Hide
Pre-order the Magento 2 payment integration course TODAY PRE-ORDER
Hello. Add your message here.