use "Connection: close" of file_get_contents

otherwise php will do keepalive request, and wait timeout seconds before
can return actual response. similar problem does not happen with curl
backend