Does anyone have ideas for a strategy to push content to a CDN upon deployment?
The key issue I'm facing is that we have a site that is available in various contexts: local development, development server, staging, then finally live.
The liver version of the site needs to load assets from a domain, which will be pointed to a CDN: assets.domain.com.
However, we will have numerous references to the assets pointing to a relative folder, e.g. /images/ in css, possibly in js, and in HTML & source.
Our new site will use capistrano for deployment and it may be that we can hook in another build tool (apache ant?) or some custom script to search / replace paths.
I am wondering if anyone has had to deal with this issue before and what solutions you put in place to automate managing the CDN in terms of pushing content up to the CDN and managing html & css references to assets in the CDN.
Thanks
Imanc
Generally speaking, CDNs use pull-based caching, not push-based replication.
This is because pushing a large (considering all of their customers) amount of content into any significant number of distributed nodes is a difficult distributed systems problem, and anticipating future traffic patterns to optimise that distribution is even more difficult.
While some (e.g., Akamai) do offer the ability to invalidate content in the network, it's usually considered a 'panic switch' rather than something that you can integrate into your deployment process.
Some may also offer 'staging servers' that you can push your content onto, but it really isn't going into the CDN; rather, the CDN will just pull content from their own servers as traffic happens. This might be adequate for what you want (usually they offer FTP, SSH and other interfaces).
Otherwise, your best bet is to wait for the TTLs you've set (e.g., Cache-Control: max-age) to time out and the content to get refreshed, when the content is backwards-compatible, or to change the URLs when it isn't.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With