from.. 2011-10-09 16:44 采纳率: 100%
浏览 49

Ajax和性能/速度

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=single&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
  • 写回答

1条回答 默认 最新

  • Lotus@ 2011-10-09 19:32
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图2.0 版本点聚合中Marker的位置无法实时更新,如何解决呢?
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题