Buying a pre-configured CDN is always a good option, but sooner or later you may find out that it works not exactly as you want. Want to get the most out of your CDN (content delivery network)? Find out how to customize its edge behavior.
Imagine that the flow of content accessed with the help of CDN network is a serious of queues based on the first request for a file or some piece of content. Every queue has header characteristics like client user agent and IP, requested path to the content, and file type. These characteristics and relevant transferred content can be used to alter headers and behaviors to reach different goals.
To transform header data based on arbitrary characteristics, you need a Script Engine that is used on the CDN edges and customize it for the best possible results. There are several spheres of Script Engine application.
- 1. It can help to deliver platform specific content. What if you have three various data sets for your content depending on the client platform, but your CMS can’t distinguish between them, because it is delivered via a published web service? Script Engine will help you by matching the user agent of the visitor’s device.
- 2. TTL based on filename pattern. You have files with different cache expiration requirements, but it is identified only by complex pattern matching from within file name? Create a script that matches the substrings and place it on the queue origin to edge. This way, CDN will correctly specify the time to live on every file within the cache, as it would be done by the origin.
- 3. Redirection of regional content. If you distribute media files, you may be aware of distribution rights that matter when you publish premium content. One way to solve this problem is to activate geo blocking, but it can cause access denial error for some users. If you want better control over distribution and access to regional content, leverage Script Engine for that. A script on queue client to edge may be set up to detect IP address of the used and look for it in geo IP database. If the region is included in the allowed set, CDN service will pass the request to the origin and deliver it. If the user is located outside the allowed region, he will be given a response to view the page of eligible partners instead.
- 4. Deliver SSL and non-secure content differently. You can use a script to work with HTTPS redirects and differentiate between HTTP and HTTPS. So if you need to separate HTTP and HTTPS traffic, Script Engine will do it for you.