2 suggestions

Apr 2, 2010 at 8:16 AM
Edited Apr 2, 2010 at 8:18 AM



thanks for your great component, it's just what I want in my project, two suggesgions:


1) If I have 10+ css/js files in my page, user have to wait a long time for the 1st request when the remote resource files are being downloaded synced from remote server (eg cdn) by webclient.DownloadData, could you provide an option to download file async using webclient.DownloadDataSync()?

2) Could you provide a function to dynmaic collect all resource in one request including mater page aspx page and ascx user control and treat them as one resourceset?

eg after I set a lot if <cc:Include> tags in my front-end page, this custom control will add all these urls to HttpContext.Items and in http endrequest event it automatically package them to one resourceset and appent it to page without any config in xml file. Furthermore, if we can have an option in config file to enable this auto function for some page is much better.

looking forward to your reply   : yzhu@live.com

Apr 3, 2010 at 12:02 PM

Hi!  Thanks a lot for your suggestions.  These are great suggestions.

Regarding #1, I understand the issue that the 1st request is slow, but I'm not sure how DownloadDataAsync() can help make the request any faster though.  The server still needs to wait until the download is completed to return full content to the browser.  Or do I misunderstand anything?  Anyway, I suppose adding support for a more persistent cache than ASP.NET cache will help (see this http://combres.codeplex.com/WorkItem/View.aspx?WorkItemId=5523).

Regarding #2, this is a good idea.  There are a couple of related feature proposals (http://combres.codeplex.com/WorkItem/View.aspx?WorkItemId=5606 and http://combres.codeplex.com/WorkItem/View.aspx?WorkItemId=6253).  I need to think of a design to harmonize all these. 


Apr 3, 2010 at 2:08 PM



#1 I mean, will it be faster if the handler download all these resources parallelly by multiple threads? eg


class ResourceHandler : IHttpHandler
        private StringBuilder data = new StringBuilder();
        private int finished = 0;
        private object locker = new object();

        public bool IsReusable
                return false;

        public void ProcessRequest(HttpContext context)
            string key = context.Request.QueryString["url"];
            if (string.IsNullOrEmpty(key)) return;
            List<ResourceItem> items = RawResourceCache.Data[key];
            if (items == null) return;

            foreach (var item in items)
                WebClient wc = new WebClient();
                wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
                wc.DownloadStringAsync(new Uri(item.Url), item.Url);

            while (finished != items.Count)

        private void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
            lock (locker)
                data.AppendFormat("/******** {0} ********/{1}{2}{3}", e.UserState.ToString(), Environment.NewLine, e.Result, Environment.NewLine);


#2  another approach is to provide a gui tool to analyze all the aspx ascx and export the resources settings to your config file :)


thanks  , Ye

Apr 4, 2010 at 10:36 AM

Thanks for your suggestions.  Parallel download is definitely something I want to have.  #2 is an interesting idea;  maybe the GUI tool can even do more, like allowing edit the config as well.  I've created 2 new tickets for these items so that I can prioritize them among other things I'm working on.  Thanks again!