Skip to content

Commit 06d9dac

Browse files
committed
Allow caching accessy images.
1 parent b6f50e2 commit 06d9dac

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

api/src/multiaccessy/accessy.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,11 @@ def get_image_blob(self, image_id: str) -> Response:
295295
r = requests.request(
296296
"GET", ACCESSY_URL + f"/fs/download/{image_id}", headers={"Authorization": f"Bearer {self.session_token}"}
297297
)
298-
return Response(r.content, headers=r.headers, status=r.status_code)
298+
res = Response(r.content, headers=r.headers, status=r.status_code)
299+
res.cache_control.max_age = 86400 # Cache for 1 day
300+
res.cache_control.public = True # Allow public caching
301+
res.cache_control.immutable = True # Response will not change
302+
return res
299303

300304
def get_member_id_from_accessy_id(self, accessy_id: UUID) -> Optional[int]:
301305
if accessy_id in self._accessy_id_to_member_id_cache:

0 commit comments

Comments
 (0)