Sergej Popov
Sergej Popov

Reputation: 3021

.NET 4.5 System.Web.Optimization bundling use on CDN

I'm building a CDN, and looking for a ways to utilize .NET minification/bundling mechanism (System.Web.Optimization) there.

The question is how can I return minified bundle from MVC controller.

Note: I'm looking to use native .NET 4.5 capabilities, I do not want 3rd party solutions. I'm only looking for ways to utilize this on CDN side. Not on client application side.

Additional question: If the above is possible at all, please explain how can I take advantage of caching, which is normally achieved through adding unique query string parameter to request.

Upvotes: 0

Views: 800

Answers (1)

Daniel Powell
Daniel Powell

Reputation: 8293

The asp.net bundling and minification uses WebGrease internally.

Grab it off nuget and add just start using it. It looks like the codeplex site doesnt have any examples on there so you will need to look at the source code or download/decompile the asp.net source code to see how they use it.

For the query string parameter I believe that is mainly to prevent/aid client side caching it doesnt neccessarily have anything to do with your server side.

You haven't said how you plant to serve up the JS files from your custom CDN so I can't help much with the caching, I would highly suggest not serving them through mvc though, there will be a lot of extra things happening in the pipeline that you dont really need if all you're doing is serving static files.

Perhaps look at having some process that parses the files and sticks them in a certain directory that IIS can serve directly without delegating to asp.net

Upvotes: 1

Related Questions