From 494c954cbb8dfd618f06eb51193b472a3f23f7cd Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sat, 9 Nov 2019 22:05:17 -0500 Subject: [PATCH] Add etag to /api/v1/annotations --- src/invidious.cr | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/invidious.cr b/src/invidious.cr index 06f9e624..96c3d6e9 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -4042,7 +4042,13 @@ get "/api/v1/annotations/:id" do |env| annotations = response.body end - annotations + etag = sha256(annotations)[0, 16] + if env.request.headers["If-None-Match"]?.try &.== etag + env.response.status_code = 304 + else + env.response.headers["ETag"] = etag + annotations + end end get "/api/v1/videos/:id" do |env|