Since this question is already tagged "php" and "curl", I'm assuming you know how to use Curl in PHP.
If you set curl_setopt(CURLOPT_NOBODY, TRUE)
then you will make a HEAD request and can probably check the "Content-Length" header of the response, which will be only headers.