Migrating an Existing Application to a CDN

Moving your application from "local file" storage to CDN based file storage for content managed images and files.

 

The recommended migration strategy is a staged process designed to keep a production site available as much as possible, and should involve little or no downtime.

Stage 1: Preparing the Code

Most CDNs serve content from a domain other than the application one (the "local" CDN being the obvious exception). In many cases FarCry will take care of using the relevant domain automatically, but there are two cases where you may be referring directly to a file in your own code: files and images. You will need to make the following changes to prepare to a CDN that isn't on the same domain as the application:

files

All files should be linked to via /download.cfm, where FarCry will take care of file security and location. The format for these links is:

/download.cfm?downloadfile=[content objectid]&typename=[content typename]&fieldname=[file field]

images

Images in code should either:

Stage 2: Migrating Existing Files

  1. In /projects/yourproject/config/_serverSpecificVarsAfterInit.cfm add the new CDN. In Stage 3 you will be making it the default for core locations, but first you need to add it as a new location. This way you can copy existing files to it while still serving them from the old location. Refer to CDN Types above to see examples of this. Remember to name your new locations something non-standard (like new-images).
  2. After updating your application, open the CDN Migration Tool (Webtop -> Admin -> Developer Utilities -> Diagnostics -> CDN Migration Tool). Select the old and new locations and click Compare. NOTE: you will need to enter filter by /images for the images location.
  3. Select the files you want to upload and click Copy Files

It's a good idea to lock down content with your admin users during Stages 2 and 3. If you can't do this, you will have a period during Stage 4 where some files aren't available to users.

Stage 3: Switching the Application to the CDN

Go back to /projects/yourproject/config/serverSpecificVarsAfterInit.cfm and update the CDN locations with the core names. Update the application.

Congratulations! Your application is now serving content from the CDN!

If you couldn't lock down content during Stages 2 and 3, you should make sure to keep the default configs available (see CDN Types examples) and go on to Stage 4.

Stage 4: Cleaning Up Files Uploaded During Migration (optional)

This stage is only necessary if you couldn't lock down content during the migration. In this case you should now have the core locations using your CDN, and some non-standard locations that still refer to the old locations.

Now you can use the migration tool (from Stage 2) to copy missing files. The tool will highlight files that are already there and those that aren't.