PDA

View Full Version : [CLOSED] GZiped StoreResult



RCN
Nov 26, 2014, 1:49 PM
Hi folks, AFAICS, the store result uses GZip, so it was expected to transfer 37 kb rather than 260 kb (unziped)

Any ideas?

http://forums.ext.net/attachment.php?attachmentid=16641&stc=1



<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
</head>
<body>
<ext:ResourceManager runat="server" GZip="true" />
<ext:GridPanel runat="server" Title="Records" Frame="false" Width="500" Height="500">
<Store>
<ext:Store AutoLoad="true" ID="_str" runat="server">
<Proxy>
<ext:AjaxProxy Url="/Example/LoadFakeRecords/">
<ActionMethods Read="POST" />
<Reader>
<ext:JsonReader RootProperty="data" />
</Reader>
</ext:AjaxProxy>
</Proxy>
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="ID" Type="String" />
<ext:ModelField Name="Name" Type="String" />
<ext:ModelField Name="Address" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column Text="ID" DataIndex="ID" runat="server" />
<ext:Column Text="Name" DataIndex="Name" runat="server" />
<ext:Column Text="Address" DataIndex="Address" runat="server" />
</Columns>
</ColumnModel>
</ext:GridPanel>
</body>
</html>




public class ExampleController : System.Web.Mvc.Controller
{
public ActionResult Index()
{
return View();
}

public StoreResult LoadFakeRecords()
{
List<Person> lst = new List<Person>();

for (int index = 0; index < 5000; index++)
{
lst.Add(new Person
{
ID = index,
Name = string.Format("Name{0}", index),
Address = string.Format("Address{0}", index)
});
}

var result = new StoreResult(lst, lst.Count());

var serializedResult = JSON.Serialize(result);

//260KB
decimal sizeOfResult = System.Text.Encoding.UTF8.GetBytes(serializedResul t).Length / 1024;

//37kb
decimal sizeOfGzipedResult = CompressionUtils.GZip(serializedResult).Length / 1024;

return result;
}
}

public class Person
{
public int ID { get; set; }

public string Name { get; set; }

public string Address { get; set; }
}



StoreResult


public override void ExecuteResult(ControllerContext context)
{
NodeCollection nodes = this.Data as NodeCollection;
StoreResponseData storeResponse = new StoreResponseData(this.IsTree || nodes != null);
if (nodes != null)
{
storeResponse.Data = ((NodeCollection)this.Data).ToJson();
}
else
{
if (this.Model != null)
{
storeResponse.Data = ModelSerializer.Serialize(this.Data, this.Model, this.IgnoreExtraFields);
}
else
{
storeResponse.Data = JSON.Serialize(this.Data);
}
}

storeResponse.Total = this.Total;
storeResponse.Success = this.Success;
storeResponse.Message = this.Message;
storeResponse.Return();
}


StoreResponseData


[Description("")]
public virtual void Return()
{
CompressionUtils.GZipAndSend(this);
}

RCN
Nov 26, 2014, 3:29 PM
On ie, the received column shows the total size of uncompressed data. But on response header it's possible to see that the data is compressed as expected. On Chrome, the received column shows the size of compressed data, as i expected.

Please, mark this thread as closed.