Skip to content

Commit 4164b01

Browse files
committed
Fix (web): Fix player trend graph to refresh according to IMAGE_UPDATE_INTERVAL
1 parent 450ac22 commit 4164b01

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

web/trend_graph.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,13 @@
9494
$cache_image = IMAGE_PATH . "/progress/trend_{$player}_{$last_time}.png";
9595
if (file_exists($cache_image))
9696
{
97-
header('Content-type: image/png');
98-
readfile($cache_image);
99-
exit();
97+
$file_timestamp = @filemtime($cache_image);
98+
if ($file_timestamp + IMAGE_UPDATE_INTERVAL > time()) {
99+
header('Content-type: image/png');
100+
// header("Cache-Control: public, s-maxage=" . IMAGE_UPDATE_INTERVAL . ", max-age=" . IMAGE_UPDATE_INTERVAL); // Cache it in the browser
101+
readfile($cache_image);
102+
exit();
103+
}
100104
}
101105

102106
$Chart = new pChart(380, 200);
@@ -154,7 +158,9 @@
154158
0, 0, 0, 0, 0, 0, $color['red'], $color['green'], $color['blue'], FALSE);
155159
}
156160

157-
$cache_image = IMAGE_PATH . "/progress/trend_{$player}_{$last_time}.png";
158161
$Chart->Render($cache_image);
159-
header("Location: $cache_image");
162+
// header("Location: $cache_image");
163+
header('Content-type: image/png');
164+
// header("Cache-Control: public, s-maxage=" . IMAGE_UPDATE_INTERVAL . ", max-age=" . IMAGE_UPDATE_INTERVAL); // Cache it in the browser
165+
readfile($cache_image);
160166
?>

0 commit comments

Comments
 (0)