CDN for online stores: what you gain and what can break
A CDN brings your images and files closer to your customers and protects you from attacks. Well configured, it is one of the improvements with the best cost-benefit ratio.
A CDN (content delivery network) is a network of servers spread around the world that keep copies of your store's static files (images, CSS, JS, fonts) and serve them from the point closest to the visitor.
What you gain
- Faster images and files, especially for visitors far from your server.
- Less load on your server, which is left to generate pages only.
- Many CDNs include protection against denial-of-service attacks and bots.
Two ways to use it
- For static files only: PrestaShop lets you configure media servers in Advanced Parameters > Performance. Images, CSS and JS are served from another domain.
- As a proxy for the whole domain (the model of Cloudflare and similar services): all traffic goes through the CDN, which decides what to store.
What can break
- Cached dynamic pages: if the CDN stores HTML, a customer can see another customer's cart or price. The cart, the account, the checkout and anything that depends on the session must bypass the cache.
- Customer IPs: behind a proxy, your store sees the CDN's IP. Anti-fraud modules, geolocation or back office whitelists stop working unless the real-IP headers are configured.
- Old files: after a CSS change, the CDN may keep serving the old version. PrestaShop adds versions to combined files, but check the purge.