Website caching is one of the most beneficial technologies available. Azure CDN allows a Sitecore 9 application to serve media from a geo-located edge server.
Caching Reduces Infrastructure Consumption
- High Availability 99.999% uptime
- Rapid Scalability to handle peak load times
- SSL offload handshake with the end user on behalf of the origin server
- Edge routing TCP termination and optimize routing back to the origin server
- Increased user satisfaction
- Better SEO scores
CDN Request Flow
- Your browser requests the image from the CDN endpoint
- The requested content is not in the CDN endpoint
- CDN calls your website origin host
- Website returns the content and adds to CDN cache
- CDN returns content to user
If the content has previously been called with the same parameters, then the CDN has it in cache and returns it to the user. It is recommended to implement deployment versioning for changing content. If the content path is not changed the CDN edge servers will not return to the origin to get the new version. Good practice would be to enable the Azure CDN TTL/Cache expiry. This will purge all content on a schedule.
Assigning the correct cache type based on the content being served will adjust how the CDN handles caching on the edge servers. Please review the Microsoft documentation below. When initially setting up a CDN with Sitecore most of the content will be set to Cache-Control: private which will ignore the azure CDN edge servers.
If an individual item needs to have a more aggressive purge, then you can set the cache-control: max-age variable to check more frequent. Please review the Microsoft documentation below.
Azure CDN Rest API
Writing a PowerShell script to run on a schedule will help with the CDN TTL/Cache expiry settings. Please review the Microsoft documentation below.