From b6f3d93f02fbf3adf376f9fbaad8cc739b8d3145 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Wed, 3 Oct 2012 22:13:11 +0200 Subject: [PATCH] no_cache management added --- web/Obj/brisk.phh | 11 +++++++++++ web/Obj/sac-a-push.phh | 2 +- web/briskin5/Obj/briskin5.phh | 6 ++++++ web/commons.js | 1 + web/xynt-http-streaming.js | 3 ++- 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index b52c333..af2a901 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -293,6 +293,13 @@ function mop_flush() 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) { @@ -2179,6 +2186,8 @@ class Room { $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; @@ -2189,6 +2198,8 @@ class Room { $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; diff --git a/web/Obj/sac-a-push.phh b/web/Obj/sac-a-push.phh index 4a325da..e57879f 100644 --- a/web/Obj/sac-a-push.phh +++ b/web/Obj/sac-a-push.phh @@ -284,7 +284,7 @@ class Sac_a_push { } $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 "); diff --git a/web/briskin5/Obj/briskin5.phh b/web/briskin5/Obj/briskin5.phh index 2bdb236..f4e266d 100644 --- a/web/briskin5/Obj/briskin5.phh +++ b/web/briskin5/Obj/briskin5.phh @@ -747,6 +747,8 @@ class Bin5 { $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) { @@ -1269,6 +1271,8 @@ class Bin5 { $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; @@ -1280,6 +1284,8 @@ class Bin5 { $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; diff --git a/web/commons.js b/web/commons.js index f0ea078..99a2983 100644 --- a/web/commons.js +++ b/web/commons.js @@ -249,6 +249,7 @@ function send_mesg(mesg) // 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') { diff --git a/web/xynt-http-streaming.js b/web/xynt-http-streaming.js index 0cbf36b..7d216aa 100644 --- a/web/xynt-http-streaming.js +++ b/web/xynt-http-streaming.js @@ -39,7 +39,8 @@ http_streaming.prototype = { 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, -- 2.17.1