0

I am redesigning all of our public-facing websites. These sites will share most assets such as JS, images, CSS, web services, etc., but will be accessed under different domains/subdomains.

I can't be the only person wanting to share all of these resources with common, but separate and unique sites. What is the proper way to go about this?

2 Answers 2

1

The best way is to have a site such as "static.mydomain.com" which hosts your javacript, images, and css. You'll typically have this site set up for some aggressive caching.

For web services, have a site called "services.mydomain.com" which hosts all of your web services.

All of the other sites go to their respective domains.

The main sites will reference all of their artifacts through something like <img src='http://static.mydomain.com/images/myimage.jpg' />

The only real complexity here is with your automated builds. But even that isn't too hard depending on your build server.

Yes, this is a pretty common approach. Further by separating out those static artificats, it makes it easier to shift them to a CDN at a later date if you want.

Sign up to request clarification or add additional context in comments.

7 Comments

I like this. How about this: how does one point to different URLs (static.mydomain.com, .dev, .qa) depending on environment without doing a bunch of codebehind work or complicating the actual coding of markup?
@Steve Costello: config files.. You can use config transformations so that you automatically swap out the settings based on the build you are doing
Oh, I get that. But I mean specifically if I am refering to, say, an image in the mark. My HTML in DEV should point to static.domain.DEV/images (since the image will not yet be in production), but in production, that same src would point to static.domain.COM/images - since this code is in the markup, and not server-dependent code, what is the best way to go about automagically making those URLs point to the correct place?
@Steve: I can think of a couple ways to do this. The first is a simple modification to your local host file that retargets the regular "static.domain.com" to a test server. The second involves a HttpModule which would intercept urls pointing to "static.domain.com" and change them out to "static.domain.DEV" if it's turned on. Similar to URL rewriting.
@Steve: Look at the following for a simple way to rerwite the entire url. weblogs.asp.net/owscott/archive/2010/01/26/…
|
1

If you want all the files to be part of the same solution then it is very similar to the problem of Sharinging Master Pages across Projects

Checkout the links on that question and the following links:

If you're only concerned about sharing static files, not dynamic, then I'd suggest following Chris Lively's advise and host them on a separate domain. Customize your build process to copy the files when necessary.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.