AssetBooster
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:Helps asp.net and .net mvc sites improve performance by housing static assets - js, css, images, etc - on a CDN. Asset Booster is used at build time and avoids pitfalls of dynamic processing. It's super testable and reliable and gets out of your way during development.
Assets - javascript, css, images, etc - are an important part of your web site.  Most sites deliver the assets from the web server without any compression.  Bummer, since assets could be delivered much more effectively, which would boost the performance of the site.  From Yahoo’s guide on site performance, you should:
1. Combine assets.  If you have a bunch of js or css files that you generally include together, like jQuery and some plugins - consider combining them into a single file.  This will reduce the number of http requests for your visitors.
2. Use a Content Delivery Network.  Your server is at one single location.  CDNs copy your content into various servers all around the world.  So if your web server is in Canada, someone in Miami would get your site assets much quicker because the CDN has a server in South Beach.  By doing this, you free up the server to process only page requests, which could also speed things up.
3. Cache.  With the proper http headers, you can prevent a browser from constantly downloading the same asset file.  This will result in much faster rendering time on other pages and revisits.
4. Minimize.  Javascript and CSS sheets typically have comments and whitespace.  In production, whitespace should be cleared out.  And javascript could be compressed even further by shortening variable names and whatnot.
5. Compress.  The vast majority of browsers support gzip decompression.  This means you can zip your assets - typically js and css - and the browser will automatically decompress.  Gzip typically reduces asset files sizes by 70%, which means faster asset loading, which means faster web site.


Sounds great, but isn’t that a lot of work?  Yes, it is.  And, lots of solutions create problems that disrupt development, deployment, and troubleshooting.   That’s why Asset Booster was made.  Booster does all the grunt work of processing and deploying assets.  It also helps you generate the proper html needed to link to your optimized, CDN-based assets.  Best of all, it allows you to use local assets during development.  So your development experience doesn’t change.  All you need to do is run a single exe and Booster handles the rest.


Booster was built for www.takeoffvideo.com, an ASP.NET MVC web app used by thousands of people.  The main developer, me, couldn’t sleep properly until all the aforementioned techniques were put into place.  After failing to find the tool for the job, I made it myself.  


Check out Takeoff’s source code:
Production:

That javascript file is created by Booster.  


Now what does that look like during development?  It’s just a bunch of separate, comment-laden javascript files:


What’s the code for it:
Razor: @Html.JsLib(“main”)  WebForms: <%=Html.JsLib(“main”) %>


Pretty slick, right?


Getting Started
Let’s get this thing going!
1.  Set up CDN
Amazon has built an amazing ecosystem of cloud products called Amazon Web Services (AWS).  One of them is CloudFront.  CloudFront is a high performance CDN with pay-as-you-go pricing.  It has “edge” servers placed all around the world, serving your content lightning fast.  Your bill will typically be a few bucks at the max.  Booster currently works only with CloudFront and if someone wants to support a different CDN (like Azure), let me know.


CloudFront typically uses another AWS product called S3.  S3 is a cloud file storage service.  Think of a rock solid, infinite web-based hard drive.  Lots of web apps, such as DropBox, run off S3.  CloudFront works by pulling files from S3 as they are requested. 


Booster uploads the files to S3 and hence CloudFront.  It also includes a little utility to perform the initial setup work, ignitebooter.exe, although if you want you can perform the work yourself using Amazon’s web-based console.  The setup really only takes a few minutes and only needs to be performed once.
Sign Up
Before you do anything, sign up for S3 and CloudFront.  To do that, go to http://aws.amazon.com/s3/ and http://aws.amazon.com/cloudfront/ and follow the instructions to sign up.  Upon signing up, you will recieve a public & private access key.  Keep that around because Booster needs it. 


Set up  
AWS has a sweet web-based management console.  You can use it to perform a few setup steps.  There is also a slick FireFox addon, S3Fox, that does a great job of managing S3.  Or you can just use ignitebooster.exe.  


Using ignitebooster.exe


DIY
Create a bucket


2.  Configure Asset Libraries
Out of the box, Booster will deploy typical asset files - png, jpb, jpeg, bmp, and swf - automatically.  Javascript and CSS requires a bit more work.  This is because those files can be combinied, minified, and gzipped.  But in order to combine them, Booster needs to know which ones should be combined.  This is done by specifying “libraries” in the web config.


Yes, when you add a new js or css you have to add it to the web.config.  Luckily you don’t have to add any 



				
			
		
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。