开发者

Ajax and Performance/Speed

I'm currently creating a small todo site, and I have multiple questions related to ajax and performance... So here are my questions:

  1. In order to reduce number of request, I want to get all data from one request, so I will pass for example these attributes:

    1.1. to get 1 task:

    entity=task&id=2&type=sin开发者_如何学JAVAgle&extra=subtasks%%contexts

    1.2. to get list of tasks and events in one listing:

    entity=task%%event&user_id=2%type=multiple%order=date&limit=10

    Do you think it will reduce number of request and improves some how the performance?

  2. If all requests will go to one file, it means that that .php file might be quite big, is it bad? Or it not really matter?

  3. For the listing. I will be able to change the order of listing and maybe filter it somehow. Do you think it will be better to load all tasks and event to


To keep things fast there are two concerns:

  1. Reduce HTTP requests – if you need two separate bits of data, send them in one file.
  2. Keep the content delivered in each AJAX request small – gzip and caching works wonders here.

So, yes, bundle things together. Large PHP file doesn't make any difference, DB queries are the only real bottleneck in a normally trafficked webpage.

For filtering and sorting, a good approach is to use JSON for the AJAX response, then sort/filter based on that on the client side if you are talking about a smallish number of items (probably upto 1000 items). If you have 100s of thousands of items, then returning a subset from the server will be better.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜