Sending large KB string of data from server to client - make string smaller size and still use in JS

websss
websss used Ask the Experts™
on
I have a Asp.net MVC app which sends a float array data to the client

float[320,240]
See attached for the data, its around 1.4mb

I need to dramatically reduce this size, and be able to convert it to the current format in Javascript

Here is the request
 $.ajax({
  type: "POST",
  url: "@Url.Action("CameraChange", "Home")",
  async:true,
  data: "{'cameraId':'" + ID + "'}",
  contentType: "application/json; charset=utf-8",
  dataType: "json",
  success: function (response) {
                 imageTemperatureDataArray = JSON.parse(response.TemperatureDataArray);
  },
   error: function (e) {
       alert("error: " + e.message + ' ');
  }
 });

Open in new window


Then I use it futher down in
 
  $("img#schemesImageSchemes").mousemove(function (e) {
       $('#dataSchemes').text(imageTemperatureDataArray[myX][myY]);
});

Open in new window


Is there a way to reduce this size of the attached
And how would i then convert it in JS ?
floattemparray.txt
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Shaun VermaakSenior Consultant
Awarded 2017
Distinguished Expert 2018

Commented:
Do you have control over the MVC app and the application running on the client?

You can GZip or something like msgpack
https://msgpack.org/
websssCEO

Author

Commented:
Yes, it's one app
When I say client I mean client side /javascript end
Multitechnician
Top Expert 2014
Commented:
you can use the compression at the webserver side level.
here a random link :
http://dotnetmentors.com/aspnet/how-to-enable-http-compression-in-asp-net-website.aspx
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013

Commented:
Is the data coming from a database or a text file? If you are trying to solve a speed problem are you sure the issue is not with the db?  Caching the file as a text file if possible or paging chunks of data via ajax.
websssCEO

Author

Commented:
Thanks
Its coming from a file, Dev tool bar shows me 1.4mb of content download.
websssCEO

Author

Commented:
Compression is already on
And in chrome Dev tool bar is see gzip accept parameter in header
Its still showing same size on content download as the actual file size
leakim971Multitechnician
Top Expert 2014

Commented:
On the chrome dev tools, go on the network tab, check "Disable cache" and if needed "Preserve log", launch your code to download the file, and check the size column for the ajax call line. If you see only one line (1.4MB), that mean your IIS server did not compressed your file. If you see two lines, 1 with the compressed size and the other 1.4MB, you're ok.
If not OK, you need to add the mime type application/json
websssCEO

Author

Commented:
thanks, i've got this in my config
    <urlCompression doDynamicCompression="true"  doStaticCompression="true" />
    <httpCompression>
      <dynamicTypes>
        <add mimeType="application/json" enabled="true" />
        <add mimeType="application/json; charset=utf-8" enabled="true" />
      </dynamicTypes>
      <staticTypes>
        <add mimeType="application/json" enabled="true" />
        <add mimeType="application/json; charset=utf-8" enabled="true" />
      </staticTypes>
    </httpCompression>


this is request headers
Accept: application/json, text/javascript, */*; q=0.01
Accept-Encoding: gzip, deflate
Accept-Language: en-GB,en-US;q=0.9,en;q=0.8
Connection: keep-alive
Content-Length: 17
Content-Type: application/json; charset=UTF-8
Host: ommited
Origin: http://ommited
Referer: http://ommited
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36
X-Requested-With: XMLHttpRequest

Open in new window



and this in response headers
Cache-Control: private
Content-Length: 1489534
Content-Type: application/json; charset=utf-8
Date: Tue, 21 May 2019 13:43:28 GMT
Server: Microsoft-IIS/10.0
X-AspNet-Version: 4.0.30319
X-AspNetMvc-Version: 5.2
X-Powered-By: ASP.NET

Open in new window


But its still 1.4mb even if i do the dev tool bar trick
leakim971Multitechnician
Top Expert 2014

Commented:
so you see one line here instead 2 like 125KB and 1.4MB :

arrow.jpg
websssCEO

Author

Commented:
Yes just one line

devtools

After disabling cache
with cache off
websssCEO

Author

Commented:
ohh IIS didn't have dynamic compression installed (despite it letting me tick that box in IIS)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial