Kaynağa Gözat

add avatars eTags

George S. Baugh 3 yıl önce
ebeveyn
işleme
151ddc011f
1 değiştirilmiş dosya ile 8 ekleme ve 1 silme
  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