I just moved one of my blogs to a new host (yay!). This blog uses MaxCDN for its content delivery, and moving the blog to a new host messed up the site’s styles and it took me a while (plus some back and forth with support) to get everything fixed because MaxCDN was still referencing the old host.
In case I ever do this again, here’s what needed to be done to move my WordPress blog to a new host with MaxCDN as my content delivery network.
Step 1: Add a CNAME record to your new host
My new host has CPanel (Digital Ocean, by contrast, had a Networking tab with a link to Domains and their records were accessible through there). If you have CPanel, click on Simple DNS Zone Editor.
Add a new CNAME record. It’ll probably look something like this:
Name cdn1.yoursitename.com. Record cdn1.yourbusinessname.netdna-cdn.com
(Your CPanel might add the . at the end of name for you, and it might autocomplete for you if you just type the subdomain portion and then tab out of the field.)
MaxCDN has good documentation on updating CNAME records for a variety of hosts, too.
Note: I use a custom domain in MaxCDN because I don’t want it to use the default “business name” URL that MaxCDn gives you.
Step 2: Update the Origin IP over in MaxCDN’s settings for your pull zone
Go to Zones > Pull Zones > Settings and get into that particular pull zone’s settings. At the bottom is Origin Information. Check the checkbox and enter the IP address for your new host. Click Update button to save.
Step 3: Whitelist your new IP
Go into your Account > look under the API section > click Manage > add your new IP as a whitelist IP.
You may also need to whitelist your own IP address, if you get problems with cURL requests failing when you try to clear CDN cache.
Step 4: Update your WP caching plugin
You may need to reconfigure your WP cache plugin. I use W3 Total Cache which, for reasons unbeknownst to me, likes to replace my entry for “Replace site’s hostname with:” with the word “Array” instead of the URL I give it.
For reference, “Replace site’s hostname with:” should be followed by your cdn url, like cdn1.yoursite.com.
Step 5: Purge all caches and check your site
When you’ve done all of the above, purge your CDN cache and your WP cache via your caching plugin.
It might also help to flush your local DNS. I’m on Windows and I do that in a command prompt with ipconfig /flushdns
Open a Chrome incognito tab and load your site – if your styles and images load, you’re good to go. If your site looks incomplete, look in the console for an error message. I found many of them (like 502 bad gateway) to be covered in MaxCDN’s documentation.
More tools for debugging DNS, caching issues
If you’re having problems, try these tools:
Did it propagate yet? Whatsmydns.net is a great way to check propagation and see what is actually getting served when you try to hit your CDN’s URL.
If you are using a custom domain with MaxCDN like I am, then putting that custom domain into whatsmydns should yield the actual “business” domain in the results list. In other words, if you search for cdn1.yourcustomdomain.com and you get responses of cdn1.yourbusiness.netdna-cdn.com, you’ve got it set up correctly.
What’s your site’s IP? In a command prompt / Terminal window, ping yoursite.com to get its IP address.
Is your CDN URL responding? In a command prompt / Terminal window, ping cdn1.yourcustomdomain.com and see if you get anything. If it can’t find your host, this could indicate an error with your CNAME record with your new hosting service.
Are you seeing stale or current stuff in your browser? I use Chrome incognito because each window starts with a fresh cache and no cookies. CTRL SHIFT N opens up a new incognito window.
You may also want to flush your DNS in between tests. ipconfig /flushdns does this in Windows.
If all else fails, email MaxCDN’s customer support. Even on a US holiday, I got a response within 20 minutes and they helped me get things working again.