It was just over a couple of years ago when I wrote the Azure CDN Concept blog post.
I was recently asked by a customer to apply caching rules to only a specific set of file extensions using a custom domain name. So with this in mind, I thought I would share the process with you.
Step 1 – Which CDN?
Microsoft Azure provides a number of CDN, so we need to find the correct CDN to meet requirements which are custom caching rules and custom domain HTTPS.
Looking at the Compare Azure CDN Product Features page it shows that only Standard Verizon and Premium Verizon will meet the requirements.
In this case, I will start by using Standard Verizon, we can migrate to Premium Verizon if needed.
Step 2 – Caching Rules
Azure CDN uses the HTTP caching specialisation RFC 7234. It should be noted that not all resources can be cached in particular Standard Verizon only deals with:
- HTTP Status Codes 200
- HTTP Methods GET
- File Size Limits 300GB
By default Standard Verizon caches any HTTP Status 200 Codes for 7 days. To override this, we need to enable Global Caching Rules which affect the caching behaviour for all requests.
In this case we want to set the caching behaviour to ‘Bypass Cache’ meaning that no content which will be cached.
Next we then set our specific Custom Caching Rules which supersede the Global Caching Rules using File Extension types for example:
We are now utilising the Standard Verizon CDN to only cache jpg, jpeg, png and gif file extensions.
In a nutshell Custom Caching Rules override, Global Caching Rules which override Default Caching Rules.
Think of it like a game of top trumps, for those of you who don’t know what this is, I would suggest adding a pack to your Christmas list!