开发者

Processing data server-side vs client-side

开发者 https://www.devze.com 2023-02-11 22:32 出处:网络
I\'m using PHP to pull financial data from yahoo. Then I\'m sending the data in JSON format to one of my Typepad blogs and receiving it with JavaScript.

I'm using PHP to pull financial data from yahoo. Then I'm sending the data in JSON format to one of my Typepad blogs and receiving it with JavaScript.

Is it faster to process the data on the server-side, then send the JSON subset to JavaScript. Or would it be better to send the whole thing, then process it with JavaScript on the 开发者_Python百科client side?

How do I learn how to make this type of trade-off analysis on my own?


Mostly good estimating. Sending large amounts of data to the client for processing will incur client overhead and make their browsing experience less acceptable. Processing data server side will increase your server load per client.

This is a common situation seen with large tables of data that are sortable or paginated. You can either do that entirely in browser or enable server side sorting and paignation. My rule of thumb is if I have more then 10k cells (10 columns x 1000 rows) then I should probably enable server side processing instead of leaving it up to the client. This is especially true on older machines with shitty slow JavaScript engines.


I find it safe to assume that my clients would have the shittiest computer, and making them do processing is not really what I want. So I mostly do server-side processing - unless it's really basic stuff like simple sorting etc etc.

Also, don't assume JavaScript is enabled. You have to fall back gracefully and that would require the server to do the processing anyhow.


Well, it depends. If you process the data server side, you'll have to wait for return from Yahoo! and then output the resulted JSON and HTML page.

If you process the data on the client side (i.e you make requests with javascript) you'll have loaded page and you can give the user some kind of notification, that the data is loading.

About that which will be faster - better run some tests. It's the best way to see :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号