Thursday, December 12, 2013

Saving my users 3.5MB in downloaded data

Some may call it a micro-optimisation but I call it "pride in craftsmanship". Here's a little Azure config tip if you're hosting your app's web service there running ASP.Net MVC or WebAPI.

Simply add this to Global.asmx.cs

protected void Application_PreSendRequestHeaders()
{
  Response.Headers.Remove("Server");
  Response.Headers.Remove("X-AspNet-Version");
  Response.Headers.Remove("X-AspNetMvc-Version");
  Response.Headers.Add("Arr-Disable-Session-Affinity", "True");
}

If you're not running on MVC you can exclude the "X-AspNetMvc-Version" line.
If you need session affinity in your requests then you'll need to exclude the last line too. Hopefully you've built a nice stateless REST service API so it's not needed though. ;)

This allowed me to change the response headers from:

HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 118099
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/8.0
X-AspNetMvc-Version: 4.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Set-Cookie: ARRAffinity=714c53d6b632a8f0cb8d9df96bafc60e300af0e3709b2c58e8e56273d9fc4120;Path=/;Domain=mir.azurewebsites.net
Set-Cookie: WAWebSiteSID=10eb484b1b294411b6aac209166dbe9b; Path=/; HttpOnly
Date: Thu, 12 Dec 2013 22:21:31 GMT

to:

HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 118099
Content-Type: application/json; charset=utf-8
X-Powered-By: ASP.NET
Set-Cookie: WAWebSiteSID=cd9d0b49a2ea4f2986c535ed9bba9ea4; Path=/; HttpOnly
Date: Thu, 12 Dec 2013 22:46:15 GMT

Cutting out:

Server: Microsoft-IIS/8.0
X-AspNetMvc-Version: 4.0
X-AspNet-Version: 4.0.30319
Set-Cookie: ARRAffinity=714c53d6b632a8f0cb8d9df96bafc60e300af0e3709b2c58e8e56273d9fc4120;Path=/;Domain=mir.azurewebsites.net


That saves 206 bytes per request.
Now if the request is made by a periodic background agent that means the request will be made approximately 48 times a day, 365 days a year.

That adds up to 3524.53 KB per year. Not a massive amount but every little helps when saving users data.
I made this change as part of some other optimisation work (that I might eventually blog about) but thought it was worth sharing here as it's easy to apply to a wide variety of uses.



2 comments:

  1. Not merely can it seem omega replica sale fantastic, in addition, it provides several actually awesome characteristics, for instance to be able to utilize the again with the observe to share with which usually area of the planet receives mild. I do believe they're features this individual audemars piguet replica sale would certainly enjoy in the observe. The particular Lange Terraluna is a fantastic select that we have got enjoyed for most causes: putting it simple, that probably could be the many difficult observe ever made simply by one of many tag heuer replica uk very best brand names inside high-end watchmaking. It’s likely that I'd personally use it "inside out" with all the movements understanding that great silent celestial body period going through upwards. Value the particular classics, person. The particular Rolex Day-Date could be the hublot replica sale top regarding Rolex, as well as the Tiffany & Corp. switch could be the top of most Day-Dates. Over a NATO as opposed to sound rare metal diamond, that adjustments coming from ostentatious to be able to whispering, "I'm sporting the most effective , nor offer a really. inches My partner and i hublot replica uk acquired no time before regarded me personally any gold-watch-person, yet experiencing this kind of blend, I might gladly use this kind of everyday. Being a go-go-80s person, that is great. Great for the utmost.

    ReplyDelete
  2. chicago bears, http://www.chicagobearsjerseys.us/
    nobis outlet, http://www.wellensteyn.com.co/
    tory burch shoes, http://www.toryburchoutletonline.in.net/
    replica watches, http://www.replicawatchesforsale.us.com/
    ed hardy shoes,ed hardy,ed hardy clothing,ed hardy shoes for women,ed hardy clothing for men,ed hardy perfume,ed hardy watches
    christian louboutin, http://www.scarpelouboutin.it/
    ugg outlet store, http://www.uggboots-outlet.co.uk/
    nike huarache, http://www.nike-airhuarache.co.uk/
    nike air max, http://www.airmax2015.in.net/
    ray ban, http://www.occhiali-rayban.it/
    louis vuitton bags on sale, http://www.louisvuittonbag.us.com/
    nike air max,nike roshe,nike huarache
    canada goose outlet, http://www.canadagoose-coats.us.com/
    hermes belt for men, http://www.hermesbelts.us/
    north face jackets, http://www.thenorthfaceclearances.us.com/
    ray ban sunglasses,ray ban sunglasses outlet,ray ban,rayban,ray bans,ray ban outlet,ray-ban,raybans,ray ban wayfarer,ray-ban sunglasses,raybans.com,rayban sunglasses,cheap ray ban
    cheap oakley sunglasses, http://www.oakleysunglassesdiscount.us.com/
    woolrich clothing, http://www.canadagoosejackets.in.net/
    kkkk10 13

    ReplyDelete