Search code examples
c#asp.netasp.net-mvc-3amazon-cloudfrontcombres

ASP.Net Combres and Combres MVC with Cloudfront


Currently I am using Amazon Cloudfront to service static objects on my ASP.Net MVC3 C# site. So all static resources have http://cdn.domainname.com/ appended before the resource.

At the same time I am using combres and combred mvc to compress and combine my CSS and Javascript.

The tag to output the minimized combined files are as follows.

@Html.Raw(WebExtensions.CombresLink("siteCss"))
@Html.Raw(WebExtensions.CombresLink("siteJs"))

This produces links on my site to

<link rel="stylesheet" type="text/css" href="/combres.axd/siteCss/-63135510/"/>
<script type="text/javascript" src="/combres.axd/siteJs/-561397631/"></script> 

As you can see my cloudfront cdn isn't in front of it so I am not getting the benefits of cloudfront with these to files.

Is there anyone out there who knows how to insert my cdn without changing the source code of the actuall combress dll file?


Solution

  • I'm not familiar with Cloudfront, but with Combres (latest release) you can change the host name (which gets appended as prefix before the /combres.axd... by setting the host attribute in . For example:

     <resourceSets url="~/combres.axd"
                    host="static.mysite.com"
                    defaultDuration="365"
                    defaultVersion="auto"
                    defaultDebugEnabled="false"
                    defaultIgnorePipelineWhenDebug="true"
                    localChangeMonitorInterval="30"
                    remoteChangeMonitorInterval="60"
                    > 
    

    Please let me know if this approach works with CloudFront?