I am maing an ajax call via jquery and in server side I am using PHP. The purpose is to bring a big JSON data from server side. As the JSON size is big that is why I am using gzip compression while sending the data.
In server side;
ob_start('ob_gzhandler');
header('Content-Encoding: gzip');
Now I am seeing significant amount of reduce in data size which is being transferred. But I am seeing that the ajax call progress get stuck in between for a while (I am checking via chrome network monitoring area).
The observation is as follow;
1. Call status showing pending for around 23 sec (which is perfect as it is exactly same time to generate the JSON)
2. Data transfer starts on 24th sec, and continues to transfer 94.4 kB data in next 5 to 6 sec
3. After that it got stuck for 20 sec almost, when the time does not increase even, I mean it shows same time that stays in point 2.
4. And then suddenly it shows ajax call completed and I am getting full data and time shows directly to around 56sec. And the data size remains same that is 94.4 kb, which means no extra data has been transferred in stage 3 and stage 4
So can you please explain me the stage 3 and stage 4, I am not getting the reason of this kind of behavior.
And kind of help will be very much helpful. If you need any more information please let me know.
To me this behavior seems related to how the gzip compression works.
The timings you are seeing cannot be interpreted in the same way as w/o the gzip compression because you have more things happening:
You may need to enable "Use Large Request Rows" in the Network monitoring tab to see more detailed timing. Maybe that will also help.
(image source)
We can't tell you what is happening inside your server or on the network between you and the server. We can't comment on specific issues in your code since you've not shown us any. However...
Have you measured the response profile on the server itself?
With compression disabled?
With compression and PHP's output buffering disabled?
Why are you compressing in php and not on the webserver? Or in the SSL tier?
Have you instrumented your code to identify execution progress?
Have you profiled your code?
Does your code explicitly do an ob_end_flush() immediately followed by an exit (with any cleanup handled in a registered shutdown function)?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With