add support for prefixing urls with domain

Nov 21, 2010 at 3:01 PM

One of the recommedations Google Page Speed and Yahoo YSlow suggest is serving your static files from a cookieless domain. Advantages are parallel loading of resources and less overhead because cookies are not send to this domain.

It would be cool if we could tell Combress to prefix the generated urls with a domain specified in the xml config file. So

/Combres.axd/Set/-1121946970/

would become

http://mystaticurl.net/Combres.axd/Set/-1121946970/

Coordinator
Dec 6, 2010 at 7:56 AM

I think you could just deploy Combres (and all the resources) to the mystaticurl.net server then it should just generate the expected URL.  So no need to be explicit about the server host.

Dec 7, 2010 at 2:02 PM

That is exactly how my setup is now. I'll try to explain how my app now works. My app listens to multiple host headers, say: http://www.mywebstore.com and http://mystorestatic.net. So my webstore can be reached at two URLS, but I configured the app that pages like product browsing and stuff only are available under mywebstore.com.

All my static content however (productimages, etc) are still available under mystorestatic.net. All images I use on mywebstore.com have absolute URLS: http://mystorestatic.net/productimage1.jpg. This wil speed the intial load time for the user: http://code.google.com/intl/nl/speed/page-speed/docs/rtt.html#ParallelizeDownloads

Therefore it would be great to tell Combres to explicit prepend a domainname before the paths it generates.

Jan 25, 2011 at 3:20 AM

buunguyen, is there any plans to do this and allow domain/subdomain path in xml configuration file?

Coordinator
Jan 25, 2011 at 6:27 AM

I've added a ticket for it here: http://combres.codeplex.com/workitem/7648 so that I can remember.

Mar 2, 2011 at 7:46 PM

Hi buunguyen,

Just looked at Combres and also find that I need to prefix the Url that accessed the site, also using multiple host headers AND multiple sub domin names,

eg: tenant1.myDomain.com, tenant2.myDomain.com, tenant3.myOtherDomain.com.

In asp.net MVC, specifically the View/MasterView/ViewModel base classes I have "ApplicationRootUrl" property and prefix this to anything requiring a Url so all Urls look absolute when looking at the html source.

I am suggesting possibly adding a mode to the path called "absolute" that uses the absolute path, To get the ApplicationRootUrl I use the following code to get this:

public static string ApplicationRootUrl()
        {
            string port = String.Empty;

            if (HttpContext.Current.Request.ServerVariables["SERVER_PORT"] != null && HttpContext.Current.Request.ServerVariables["SERVER_PORT"].ToString() != "80" && HttpContext.Current.Request.ServerVariables["SERVER_PORT"].ToString() != "443")
            {
                port = String.Concat(":", HttpContext.Current.Request.ServerVariables["SERVER_PORT"].ToString());
            }

            string protocol = "http://";

            if (HttpContext.Current.Request.ServerVariables["SERVER_PORT_SECURE"] != null && HttpContext.Current.Request.ServerVariables["SERVER_PORT_SECURE"] != "0")
            {
                protocol = "https://";
            }

            return String.Concat(protocol, String.Concat(HttpContext.Current.Request.Url.Host, port, HttpContext.Current.Request.ApplicationPath, '/').Replace(@"//", @"/").ToLower());
        }

Hope this helps....

Mark

May 8, 2011 at 10:56 AM
Edited May 8, 2011 at 11:09 AM

This would also allow for much easier integration with a 'pull' type of cdn for delivering files managed by combres - definately has my vote!

I should also mention, you should support seperate http/https prefixes - as most setups use different subdomains for https

Coordinator
May 29, 2011 at 6:04 AM

I've introduced a <host> attribute to the root setting.  This will be used as the prefix to the domain.  The generated URLs for resource sets (and resources in no-pipe-line-debug mode) will used this as a prefix to form the absolute URL.  This change is both in the trunk and latest NuGet package (2.2.1.9).  If somebody could give it a try and let me know if this change helps with what you want to achieve or not, that would be great.

May 29, 2011 at 11:35 AM

Buu,

This is awesome - and almost exactly what I needed. Literally the ONLY change I would make is to add an sslHost attribute as well. Combres would automatically determine which one to use based upon the Request.IsSecureConnection property - does that make sense?