I've got a CDN set up for an old archival site (as subdomain) that has no CMS, just a bunch of .html, .php, and media (mainly images, Flash, and css sheets).
I figure I have at least three options:
- Create .htaccess rules to reroute appropriate local URLs to CDN ones. Advantage: easy. Disadvantage: the extra lookup may defeat the purpose of the CDN.
- Use regex to alter every local URL to
<? echo maybe_get_CDN_url("..."); ?>
and write a function that determines whether to return the local or CDN version. Advantage: centralizes CDN url in one file in case we ever switch providers. Disadvantage: smells suspiciously of over-editing (also consider theinclude
statement required in every file, plus running all .html files as .php). Luckily, since this is an archival site whose content won't be edited further, the inconvenience of creating new links with this approach is irrelevant. - Use regex to alter every local URL to a local or CDN one as appropriate. Advantage: leaves the HTML in a straightforward state. Disadvantage: must be repeated if/when the CDN provider changes. (This could be resolved by using a CNAME, of course, but the Cheap as Free⢠SSL and CDN solutions currently in place won't allow flexible enough certificates to work with this. Retort: why don't we remove SSL on this domain since security isn't an issue. Re-retort: if we do that Chrome will start marking this subdomain as insecure, and we won't benefit from HTTP/2.)
So, my question is... which is the least boneheaded of these solutions? :D
Or do any others come to mind?