分页:服务器端还是客户端?

分页:服务器端还是客户端?

问题描述:

处理分页最好的是什么?服务器端还是使用javascript动态执行?

What is it best to handle pagination? Server side or doing it dynamically using javascript?

我正在研究一个对ajax很重要并且动态提取数据的项目,所以我一直在努力一个使用dom的javascript分页系统 - 但我开始认为在服务器端处理它会更好。

I'm working on a project which is heavy on the ajax and pulling in data dynamically, so I've been working on a javascript pagination system that uses the dom - but I'm starting to think it would be better to handle it all server side.

每个人的想法是什么?

正确的答案取决于您的优先级和要分页的数据集的大小。

The right answer depends on your priorities and the size of the data set to be paginated.

服务器端分页最适合:


  • 大数据集

  • 更快的初始页面加载

  • 未运行javascript的人的辅助功能

客户端分页最适合:


  • 小数据集

  • 更快后续页面加载

因此,如果您主要是出于美观原因进行分页,那么更有意义处理客户端。如果你要分页以减少初始加载时间,那么服务器端是显而易见的选择。

So if you're paginating for primarily cosmetic reasons, it makes more sense to handle it client side. And if you're paginating to reduce initial load time, server side is the obvious choice.

当然,如果你使用Ajax,客户端在后续页面加载时间方面的优势会减少加载后续页面。

Of course, client side's advantage on subsequent page load times diminishes if you utilize Ajax to load subsequent pages.