On Wed, May 31, 2006 9:19 am, Merlin wrote:
> I am reading a remote plain text file from another server via the file
> command:
>
> $str = file ("http:/xxxxx");
> This is a feed so there is no other way then reading it remote.
>
> Now this reading takes up between 0.5 and 1.0 s which is far to slow.
> The whole other process on the site takes only 0.1 s and I would like
> to
> keep it inside this area of 0.1 - 0.2 s

What, exactly, are you measuring on that "other side"?

Think carefully about this.

Because odds are really good that you ONLY measure the time for some
process to spit "out" the data.

Yet, there is a great deal more time being spent on the "other side"

For example, if this "other side" has PHP and Apache, and you ONLY
measure the PHP start/end times, you're ignoring any Apache overhead.

How fast/slow is, say, wget from the local server?
That's probably a much more accurate measure to compare your PHP
performance with.

> Is there a faster way to read a remote txt file than with file() ?

Since file() has to read each line and build up an array, it might be
slower than http://file_get_contents

> If not, is there a way in php to process this in the background and
> continue to display the page without the results of the file?

You can use asynchronous streams/sockets to get the process started at
the beginning of your script, do other stuff, and then get the results
at the end of your script.

You could also use something browser-side like XmlHttpRequest or
full-blown AJAX to have the browser download the feed "later" --
Though even a iframe could do that, much simpler, most likely.

I would not be too hasty jumping into the iframe/ajax/client-side
solution, personally, as it tends to open up cans of worms.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to