AndyM
AndyM

Reputation: 1190

Storing CSS files on Windows Azure

I'm working on my first Windows Azure application and I'm wondering how people go about managing CSS & JS files within their apps?

At the moment my CSS and JS are just part of my cloud app so every time I make a small CSS change the app needs to be redeployed which isn't ideal. Is it best practice to remove those components from the cloud app and deploy them elsewhere? If that is the case where is the best place to store them? Inside a cloud storage account using blobs or something else?

Upvotes: 3

Views: 3203

Answers (4)

Mister Cook
Mister Cook

Reputation: 1602

I am not sure if this will work as easily as you might expect for CSS files if they are being referenced from a different domain.

CSS files that are hosted on a different domain might be blocked by the browser. See Cross-Origin Resource Sharing: http://www.w3.org/TR/cors/ However I am not sure if this is widely implemented.

An alternative might be to use a handler which forwards requests for the CSS files on your server to the blob.

Upvotes: 0

Vyrotek
Vyrotek

Reputation: 5459

We store our JS and CSS in blobs with the Azure CDN and it works great.

A completely different 'solution' might be to check out: http://blogs.msdn.com/b/windowsazure/archive/2011/07/12/now-available-windows-azure-accelerator-for-web-roles.aspx

I personally haven't used them yet but they're supposed to let you alter/update your web role projects without needing to redeploy the entire thing.

Upvotes: 1

Matt P.
Matt P.

Reputation: 43

Bear in mind that if you put your assets in storage, each time there is a page request that includes a link to storage, it counts as a storage transaction. Currently, they are priced at $0.01 per 10,000, so it would take a while to be costly. But if you have 2 CSS files, 2 JS files and 4 images on a given page, that's 8 transactions per page request.

If you get 1000 page requests per day * 30 days that's 240,000 per month / 10,000 = $0.24. Not a big deal if your page requests stay low. But, if your site is even remotely higher traffic, it can start to add up quickly.

Upvotes: 4

Drew Marsh
Drew Marsh

Reputation: 33379

Yeah, throw your assets into a public container in storage and build absolute urls to the storage account container from the web app (use a helper method). This way you can just sparsely upload assets as they change.

Next step would be to expose the container over the CDN to get the distributed edge caching too.

Upvotes: 2

Related Questions