websss
asked on
Sending large KB string of data from server to client - make string smaller size and still use in JS
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
Then I use it futher down in
Is there a way to reduce this size of the attached
And how would i then convert it in JS ?
floattemparray.txt
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 + ' ');
}
});
Then I use it futher down in
$("img#schemesImageSchemes").mousemove(function (e) {
$('#dataSchemes').text(imageTemperatureDataArray[myX][myY]);
});
Is there a way to reduce this size of the attached
And how would i then convert it in JS ?
floattemparray.txt
ASKER
Yes, it's one app
When I say client I mean client side /javascript end
When I say client I mean client side /javascript end
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
ASKER
Thanks
Its coming from a file, Dev tool bar shows me 1.4mb of content download.
Its coming from a file, Dev tool bar shows me 1.4mb of content download.
ASKER
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
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
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
If not OK, you need to add the mime type application/json
ASKER
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
and this in response headers
But its still 1.4mb even if i do the dev tool bar trick
<urlCompression doDynamicCompression="true
<httpCompression>
<dynamicTypes>
<add mimeType="application/json
<add mimeType="application/json
</dynamicTypes>
<staticTypes>
<add mimeType="application/json
<add mimeType="application/json
</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
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
But its still 1.4mb even if i do the dev tool bar trick
ASKER
ohh IIS didn't have dynamic compression installed (despite it letting me tick that box in IIS)
You can GZip or something like msgpack
https://msgpack.org/