0

I have a large JSON object of about 8 MB. If I cut down the name of variables that are duplicated in these lists will that help on the size? It’s an AJAX request coming from IIS.

{ “VenueLocationID” : 12 }

{ “vid” : 12 }
Cᴏʀʏ
  • 105,112
  • 20
  • 162
  • 194
Mike Flynn
  • 22,342
  • 54
  • 182
  • 341
  • Yes, but, what's the actual problem here? Are you trying to cut down the size, are you running into limits, are you seeing unexpected behavior in any way? – Cᴏʀʏ Sep 10 '18 at 19:46
  • Just cutting down on the response time, the shorter the better right. Instead of say 1 min, 30 seconds? – Mike Flynn Sep 10 '18 at 19:46
  • Might be easier to just enable [compression](https://learn.microsoft.com/en-us/iis/configuration/system.webserver/httpcompression/). – Cᴏʀʏ Sep 10 '18 at 19:48
  • That’s why I’m putting IIS, doesn’t it compress already? – Mike Flynn Sep 10 '18 at 19:49
  • Not by default, AFAIK -- you can enable it either in IIS or put a section in your web.config. I wouldn't sacrifice the readability of your JSON properties without first trying to enable compression. – Cᴏʀʏ Sep 10 '18 at 19:51
  • How do I know it’s not compressing or not already? I removed properties that were NULL and it drastically cut down on size. – Mike Flynn Sep 10 '18 at 19:52
  • Can you inspect the headers of your responses from IIS? If compression is enabled, you'll have a `Content-Encoding: gzip` in there. – Cᴏʀʏ Sep 10 '18 at 19:55
  • You were right, compressing it cut it down dramatically. I would assume renaming the properties would have a nil effect now. I used this method to do it for only that controller action 'https://stackoverflow.com/questions/3802107/how-to-gzip-content-in-asp-net-mvc'. If you make an answer I will accept it. – Mike Flynn Sep 10 '18 at 21:37

1 Answers1

0

I'm assuming that you have a lot of repetition of property names in your large JSON response. Instead of sacrificing the readability of your property names, I would try enabling gzip compression on your response. The gzip algorithm is particularly good at compression when there are repetitive strings fed to it.

You can enable this compression in IIS, your application's web.config file, or in code. See this MSDN article for examples.

Cᴏʀʏ
  • 105,112
  • 20
  • 162
  • 194