Youssef Mayoufi
Youssef Mayoufi

Reputation: 25

compressed a json data, angularJs

I 'm developing a web aplication with .net API and back end with angularjs restfull , problem I have big data json (4 mb) , is there a solution to reform the json data or compressed ? for optimized the response time

Upvotes: 1

Views: 2191

Answers (2)

Floremin
Floremin

Reputation: 4089

Other than using some minification library in your server-side code, you could setup GZIP compression on the web server itself. All browsers today support GZIP and will send Accept-Encoding: deflate, gzip header, so the server would know to compress before sending the respone.

Here are links to setup compression on Apache and IIS:

http://httpd.apache.org/docs/2.0/mod/mod_deflate.html

https://technet.microsoft.com/en-us/library/cc771003(WS.10).aspx

Upvotes: 1

Mustaq
Mustaq

Reputation: 121

There are few ways to compress JSON data 1) Instead of Using arrays of object, try to use arrays of array

Ex:

[{"name":"qwerty","mobile":"000112233","location":"NorthPole"},{"temp":"0 deg","sunrise":"qw","sunset":"er"}]

to

[["qwerty","000112233","NorthPole"],["0","qw","er"]]

2) Remove blank space in json object

3) if you want to maintain array of objects. then reduce size of variable name:

[{"n":"qwerty","m":"000112233","l":"NorthPole"},{"t":"0 deg","r":"qw","s":"er"}]

My suggestion is not to pass large weight data in webapi. use async calls to fetch data which is required on demand.

Upvotes: 1

Related Questions