flush();
 }
 
+function force_no_cache(&$header_out)
+{
+    $header_out['Pragma'] = 'no-cache, must-revalidate';
+    $header_out['Cache-Control'] = 'no-cache';
+    $header_out['Expires'] = '-1';
+}
+
 function file_lock($fname, $is_exclusive)
 {
     if (($res = @fopen($fname, "r+")) == FALSE) {
       $content = ob_get_contents();
       ob_end_clean();
 
+      force_no_cache($header_out);
+
       $s_a_p->pgflush_try_add($new_socket, 20, $header_out, $content);
       return TRUE;
 
           $content = ob_get_contents();
           ob_end_clean();
 
+          force_no_cache($header_out);
+
           $s_a_p->pgflush_try_add($new_socket, 20, $header_out, $content);
           return TRUE;
 
 
             }
             $write  = NULL;
             $except = NULL;
-            $num_changed_sockets = stream_select($read, $write, $except, 0, 250000);
+            $num_changed_sockets = stream_select($read, $write, $except, 5, 0);
         
             if ($num_changed_sockets == 0) {
                 printf(" no data in 5 secs ");
 
             $content = ob_get_contents();
             ob_end_clean();
             
+            force_no_cache($header_out);
+
             $pgflush = new PageFlush($new_socket, $curtime, 20, $header_out, $content);
             
             if ($pgflush->try_flush($curtime) == FALSE) {
             $content = ob_get_contents();
             ob_end_clean();
         
+            force_no_cache($header_out);
+
             $s_a_p->pgflush_try_add($new_socket, 20, $header_out, $content);
             return TRUE;
         
             $content = ob_get_contents();
             ob_end_clean();
             
+            force_no_cache($header_out);
+
             $s_a_p->pgflush_try_add($new_socket, 20, $header_out, $content);
             return TRUE;
             
 
     
     // alert("xhr_wr: "+xhr_wr+"  is_conn: "+is_conn);
     xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+'mesg='+mesg, (is_conn ? true : false));
+    xhr_wr.setRequestHeader("If-Modified-Since", new Date().toUTCString());
     xhr_wr.onreadystatechange = function() { return; };
     if (typeof(g_debug) == 'number' && g_debug > 0
         && typeof(console) == 'object' && typeof(console.log) == 'function') {
 
     keepalives_equal:  0,
     keepalives_eq_max: 6,
     /* NOTE: right watch_timeout value to 100, for devel reasons use 1000 or more */
-    watchdog_timeout:  200,
+    // FIXME watchdog_timeout:  200,
+    watchdog_timeout:  2000,
     watchdog_ct:       0,
     watchdog_checktm:  20,
     watchable:         false,