Skip to content

Commit 57c9a46

Browse files
committed
Avatar cache
1 parent dc13d49 commit 57c9a46

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

lhc_web/modules/lhwidgetrestapi/avatar.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,14 @@ public function generate($avatarId, $sansEnv, $ver) {
657657
}
658658
}
659659

660-
if (empty($Params['user_parameters']['id'])) {
660+
if ((string)$Params['user_parameters']['id'] == '') {
661+
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
662+
header('HTTP/1.1 304 Not Modified');
663+
die();
664+
}
665+
header('Content-type: image/svg+xml');
666+
header('Cache-control: max-age='.(60*60*24*365));
667+
header('Expires: '.gmdate(DATE_RFC1123,time()+60*60*24*365));
661668
echo '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
662669
<svg
663670
xmlns:dc="http://purl.org/dc/elements/1.1/"
@@ -679,7 +686,7 @@ public function generate($avatarId, $sansEnv, $ver) {
679686
M75.586,54.102A121.429 121.429 0 0 1 150,28.571A121.429 121.429 0 0 1 271.429,150A121.429 121.429 0 0 1 245.898,224.414Z
680687
M224.414,245.898A121.429 121.429 0 0 1 150,271.429A121.429 121.429 0 0 1 28.571,150A121.429 121.429 0 0 1 54.102,75.586Z"/>
681688
</svg>';
682-
header('Content-type: image/svg+xml');
689+
exit;
683690
}
684691

685692
$propsMapping = [

0 commit comments

Comments
 (0)