What to Cache - andywahr/azure-cdn-guidance GitHub Wiki
What to Cache
The key to effectively using a CDN is to pick the appropriate content to Cache. The CDN Primer talks about the kinds of content. But normally, sites are a rich mixture of Static and Dynamic Content. This is where you can use different DNS Domains to segregate kinds of content. Here are some ideas:
Dynamic website all on one domain
Let's take a site, called www.X.com, and it has Dynamic content generated by hosted backend cluster of webservers. The Web Pages refer to Images, JS, and CSS all hosted in the application. That means all of the resources are accessed via www.X.com. The site's popularity is growing in a large geographic area and you need to improve load times. There are 2 approaches:
- Put Dynamic Site Acceleration on your entire site and add Cache rules for the paths for your static assets
- You would use Azure CDN with Akamai or Verizon Providers, and configure the rules (discussed below)
- Need to be careful that Cache Rules ONLY apply to static.
- Create a new DNS Domain for Static Assets (cdn.X.com)
Limited time event causes significant (10X or more) increase in traffic
There are certain annual events (Black Friday, Boxing Day, Singles Day, etc..) or other limited time situations (COVID-19) than causes a dramatic increase in traffic. Your site is starting to have operational or cost issues trying to keep up with the demand. There are a few strategies to leverage CDN in a way to absorb that extra traffic:
- Alternative DNS Domain with Static Site (or full Single Page Application) that is fully cacheable.
- Create a deals.X.com or covid.X.com, and publish a Static site
- Put a prominent link on your home page (www.X.com), directing users there
- Setup Dynamic Site Acceleration in front with Caching on the Home Page, either:
- Remove all Dynamic Content generated server side from your Home Page
- Make a new fully Cacheable Home page with a link to your original Home Page
- Temporarily remove any Dynamic content generated server side from your Home Page, and setup Dynamic Site Acceleration in front with Caching on the Home Page.