I’m interested in using a CDN for storing some assets in my web application. However, instead of hardcoding the CDN url into each of my assets (Javascript and CSS), I’d like to use a simple RewriteRule to redirect requests for assets to a CDN.
However, I’m wondering if there are some disadvantages to this method. For one, the server is still processing requests for assets since it needs to identify and redirect such requests. And another, I’m concerned that the CDN will look at the location of my server as opposed to the location of my client.
Has anyone ever dealt with this kind of strategy, and what was your solution? Thanks!
That’s not a great strategy, as it completely nullifies any benefits or using a CDN. For every request for a static asset, your server has to process a request, which is exactly what you’re trying to avoid.
Bite the bullet, and set up your application to be configurable (you do use basic configuration, correct?) enough so that you change base URLs for all your static assets.