title: Syncing multiple clients triggered by a server in PHP and Javascript
body: <p>I run a server on a shared hosted space (Aruba) with LAMP configuration, with two separate sets of PHP pages, one for the administrator and one for several clients (imagine a quiz game where the administrator submits questions).</p>
  
  <p>I want to achieve this behaviour:  </p>
  
  <ul>
  <li>The administrator presses a button and released the question</li>
  <li>At any time within ten seconds (or even immediately, but not strictly requested) all the clients must display <em>AT THE SAME TIME</em> the page with the text of the question.</li>
  </ul>
  
  <p>To achieve this, I thought of different solutions:  </p>
  
  <ul>
  <li><strong>Web sockets</strong> (not feasible, as I cannot install server components on
  my web page)</li>
  <li><strong>Trigger file</strong> generated by the administrator; the clients will periodically (~10 sec) poll (<code>setInterval()</code>) for the presence of this file and, depending on the
  creation time of the file (or an equivalent timestamp read from the
  file name or file content) the client will start a countdown (<code>setTimeout()</code>) for the
  time remaining to when the new page has to be fired, to make sure that all clients eventually trigger at the same time (tenth of second)</li>
  <li><strong>Trigger via database</strong> (basically same as trigger file, but possibly slower).</li>
  </ul>
  
  <p>I tried the second solution (to manage the reading of trigger file on client-side) both in PHP and in Javascript, but they both fail when there is more than a client connected:  </p>
  
  <ul>
  <li><strong>PHP</strong> apparently fails because Apache does not support many simultaneous threads
  and gets somehow stuck  </li>
  <li><strong>Javascript</strong> somehow occasionally misses to    recognize the presence
  of the file in the local directory (with more    than one client
  connected <code>XMLHttpRequest.status</code> incorrectly returns <code>404</code> even when the trigger file is there) - I even created separate trigger files for the different clients, to make sure there are no concurrency conflicts.</li>
  </ul>
  
  <p>Any hints on why <code>XMLHttpRequest.status</code> occasionally fails, or advice on a better way of achieving this behaviour?</p>
  
  <p>Thank you in advance.</p>