views:

69

answers:

1

Google Page Speed test tells me I need to distribute my queries across DNS Domain names to speed up rendering.

Since I do development offline, I'd like to find a solution that will distribute my static content (img, CSS, js) across different hostnames, and will still work when I'm offline in an airplane.

Q: How can I code my page to use relative paths (or local host) when offline, and to consistently send static content requests among 5 hosts? After reading this I'd like the url to be similar to this:

When Online: Dynamic content
www.TLSAdmin.com

When Online: Static content
static1.TLSAdmin-Static.com
static2.TLSAdmin-Static.com
static3.TLSAdmin-Static.com
static4.TLSAdmin-Static.com

When Offline: All content
localhost

I'd prefer to make it so that the referred to hostname will be consistent after a page refresh to leverage browser caching. So a random guid.TLSAdmin.com will not be a good idea.

+1  A: 

How about this:

1) Code all you links to static resources as, for example, [HOSTNAME]/Images/myimage.jpg
2) Create either an HTTP module or a base class for your pages which implements a response filter.
3) That filter should use a regex to find all instances of [HOSTNAME] and replace with an alternative.

The filter could include logic to check if the current hostname is localhost and then just insert localhost as the hostname. To randomise the distribution of the other hostnames whilst maintaining cacheability you could do the following:

1) Have a list of alternative hostnames
2) You'd need a more complex regex/syntax to find [HOSTNAME] and also locate the file name as well
3) Create a hash of the full path of the file. This could be really simple, like counting the ascii codes of each character in the path and finding the module # of hostnames
4) Use the hash value to pick the hostname from the list.

With this, you should get a spread of requests across each hostname + the same resource will always be served from the same host so it can be cached.

Adam Pope
@Adam Pope - Sounds like a clean approach but I have never done a HTTP Module or base class in this manner. Where do I start?
MakerOfThings7
My only previous experience is when I was researching the idea of moving the ViewState to the bottom of the page. Here are a couple resources I found for that: http://goo.gl/8IY0 http://goo.gl/qXrK
Adam Pope
Here's another one http://goo.gl/Ugv1
Adam Pope