소스 검색

add avatars eTags

George S. Baugh 3 년 전
부모
커밋
151ddc011f
1개의 변경된 파일8개의 추가작업 그리고 1개의 파일을 삭제
  1. 8 1
      lib/Trog/Routes/HTML.pm

+ 8 - 1
lib/Trog/Routes/HTML.pm

@@ -735,7 +735,14 @@ sub avatars ($query) {
         users => \@posts,
     });
 
-    return [200, ["Content-type" => "text/css" ],[$content]];
+    my $headers = ["Content-type" => "text/css" ];
+    if (@posts) {
+        # Set the eTag so that we don't get a re-fetch
+        my $etag = "$posts[0]{id}-$posts[0]{version}";
+        push(@$headers, ETag => $etag);
+    }
+
+    return [200, $headers,[$content]];
 }
 
 =head2 users