diff --git a/html/inc/cache.inc b/html/inc/cache.inc index 01b470b0c0..53849b403d 100644 --- a/html/inc/cache.inc +++ b/html/inc/cache.inc @@ -28,57 +28,60 @@ function get_path($params) { } function start_cache($max_age, $params=""){ - $path = get_path($params); - $request = getallheaders(); - // Check to see if this is a conditional fetch. - $lastmodified = @filemtime($path); + if ($max_age) { + $path = get_path($params); + $request = getallheaders(); + // Check to see if this is a conditional fetch. + $lastmodified = @filemtime($path); - $if_modified_since = isset($request['If-Modified-Since']) ? + $if_modified_since = isset($request['If-Modified-Since']) ? (explode(';',$request['If-Modified-Since'])) : false; - if ($if_modified_since) { - $if_modified_since=strtotime($if_modified_since[0]); - } + if ($if_modified_since) { + $if_modified_since=strtotime($if_modified_since[0]); + } - if ($if_modified_since && ($if_modified_since == $lastmodified)) { - Header("Last-Modified: " . gmdate("D, d M Y H:i:s",$lastmodified) . " GMT"); - Header('HTTP/1.0 304 Not Modified'); - exit; - } + if ($if_modified_since && ($if_modified_since == $lastmodified)) { + Header("Last-Modified: " . gmdate("D, d M Y H:i:s",$lastmodified) . " GMT"); + Header('HTTP/1.0 304 Not Modified'); + exit; + } - if ($lastmodified diff --git a/html/user/hosts_user.php b/html/user/hosts_user.php index cee6121ad8..db51d3a99a 100644 --- a/html/user/hosts_user.php +++ b/html/user/hosts_user.php @@ -5,10 +5,14 @@ require_once("../inc/db.inc"); require_once("../inc/util.inc"); require_once("../inc/host.inc"); + require_once("../inc/cache.inc"); db_init(); $userid = $_GET["userid"]; if ($userid) { + $cache_args = "userid=$userid"; + $caching=true; + start_cache(USER_PAGE_TTL,$cache_args); $result = mysql_query("select * from user where id=$userid"); $user = mysql_fetch_object($result); mysql_free_result($result); @@ -17,10 +21,12 @@ user_host_table_start(false); } else { echo "Hidden\n"; + end_cache($cache_args); exit(); } $private = false; } else { + $caching=false; $user = get_logged_in_user(); $userid = $user->id; page_head("Your computers"); @@ -36,4 +42,5 @@ mysql_free_result($result); echo "\n"; page_tail(); + if ($caching) end_cache($cache_args); ?>