PHP vs AJAX requests and speed question..

Status
Not open for further replies.

Porsche_maniak

Active Member
283
2009
0
40
Hi guys.
I am here with an interesting question.. I will try to explain briefly.

For example you have left,middle and right section in your website. Each of them must show content in different files on your server (for example 1.txt,2.txt and 3.txt).The txt files are 512kb each.
In my case i have to do an ajax request to a php file that gets and echoes (so the ajax can take the result ofc) the content from the txt files.

So should i do 3 ajax requests(for each section) to the php file or do just 1 ajax request and then split the result in 3 parts with some separator for example.

What would be faster ? What would save more CPU usage too?

Thanks
 
3 comments
I'd say a single request would be definitely faster. CSS sprites are popular for the same reason - combining multiple requests into a single one.

And I don't think you have to worry about CPU usage for such a simple script.
 
@deliteblogger this is just example. The script will be much more complicated.
The thing is that i can complicate it as much as i want (meaning to download more variable data and show it with single ajax request)
so i was wondering if i should not complicate it so much and just do more ajax requests instead.
 
Depending on the txt1,txt2, etc file size, i would say use 3 Ajax requests would be better than splitting the text...In terms of CPU usage. Might be wrong, but splitting heavy amounts of texts causes CPU usage to go up quite a bit. Or at least happened in my case, whereas when i used ajax requests didn't seem to be too bad.
 
Status
Not open for further replies.
Back
Top