NYCPHP Meetup

[nycphp-talk] Accessing a file in another web server

csnyder chsnyder at gmail.com
Thu Jan 4 14:24:47 EST 2007


On 1/4/07, Néstor <rotsen at gmail.com> wrote:
> Tom,
>
> I had just tried this and it works but it makes the entire web page very
> slow to render.
> See the page that I am dealing with needs to do this check in several
> places.
>
> One thing is that you need to use the fopen() with an '@' to suppress
> warnings when
> the file does not exist.

The page will render particularly slowly if the other webserver goes
down, as each fopen() call will take around 30 seconds to time out.
You're right to look for another solution.

If the URLs don't change very often, you could write a quick cron
script to check for them every now and then, and update a local file
or database.

If they _do_ change a lot, then you will need to write (or find)
checking routines that make HTTP HEAD requests via fsockopen(). Not
only is HEAD more efficient then GET, but fsockopen() can be set to
have very short timeouts in case the server is unreachable or not
answering quickly.

-- 
Chris Snyder
http://chxo.com/


More information about the talk mailing list