开发者

how can i load my page faster with $.ajax() or $.post()

i am trying to load database values from 6 - 7 tables on a single page i.e users, their post e.g with $.load(); and it is taking from 15+ seconds to load but i want to load that page from 1-5 seconds ...i know it depends on internet connection speed but how can i d开发者_开发知识库o that ....


You first have to identify the problem, and you've given us no information to do so.

  1. It could be your webserver. Check the latency through firebug -- this is pretty unlikely.
  2. It could be your queries. Test them and see how long they take to run.
  3. It could be your script in general. Test it and look for potential bottlenecks.
  4. It could be the webpage itself - if the PHP runs fast (queries and script) and the data loads quickly (low latency, low delivery time) then it could be the method your using to insert the data into the page itself.


You could postpone loading database information until after the page is loaded by requesting your data-centric components through Ajax but after adding everything up it'll probably be the same amount of time to fully load your page. Your problem is more along the lines of slow hardware, slow internet connection to/from your server. I'm guessing that you're on a shared host, which is probably why you're suffering from slower speeds.


How large are these tables? How much php script processing are you doing? Have you looked at how long the queries take to run, outside of any script?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜