title: Same Image URL's returning either 24 bit or 32 bit Image on Cloudfare Server? (cURL "content-length" check)
body: <p>This is very confusing to me and I can't seem to find any information anywhere which may explain this.</p>
  
  <p>I've a database of around 1,000 image URL's and I am doing a cURL header callback</p>
  
  <pre><code>curl_setopt($this-&gt;curl, CURLOPT_HEADERFUNCTION, array($this, 'headerCallback'));
  </code></pre>
  
  <p>Which in it looks for the content-length of the image URL ...</p>
  
  <pre><code>if ($name === 'content-length' &amp;&amp; (int) $value === $this-&gt;filesizecheck) {
      curl_setopt($this-&gt;curl, CURLOPT_NOBODY, true);
  }
  </code></pre>
  
  <p><code>filesizecheck</code> just simply checks the filesize of the already downloaded image on my server. </p>
  
  <p><code>CURLOPT_NOBODY</code> setting means if the filesize on my server matches the content-length coming from the header, it instructs the system not to download the image body, and stop at the header.</p>
  
  <p>My initial idea in implementing this was to check if the image within the image URL has changed -- and if so, download and replace the image.  If not-- do the header check, and skip over it.</p>
  
  <p>What's boggling me is that sometimes the exact same image URL returns either a 24-bit or 32-bit of the exact same image. This was something I was not expecting, and is obviously throwing my <code>filesizecheck</code> off!</p>
  
  <p>Here are the headers for the image url's if it hints at anything:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
      [1] =&gt; Accept-Encoding: gzip, deflate
      [2] =&gt; Accept-Language: en-US,en;q=0.9
      [3] =&gt; Connection: keep-alive
      [4] =&gt; Host: /////
      [5] =&gt; Upgrade-Insecure-Requests: 1
  )
  </code></pre>
  
  <p>Now, this is only on one server/host I've experienced this with.</p>
  
  <p>Has anyone ever encountered the exact same image URL returning either a 24 bit (example <code>content-length</code> value: <code>397570</code> of one image) or a 32 bit image (<code>content-length</code> value: <code>501502</code>) of the same image, why this is and is there anything I can do to resolve this strange issue?</p>
  
  <p>Of course this is throwing off the entire system of doing a header check and downloading the image if it has "changed" -- sometimes it wants to download the 24 bit image, sometimes it wants to download the 32 bit image -- seems completely random as to when it returns a 24-bit or 32-bit image.</p>
  
  <p>Visually -- there is no difference in the image.</p>
  
  <p>Must I somehow get the values off both the 24-bit and 32-bit image for this to work? Does anyone know why a static image URL would return (seemingly randomly) either a 24-bit or 32-bit of the same image?</p>
  
  <p>What would be the suggested way forward? Any tips or information would be greatly appreciated!</p>