Skip to content

Commit 65ee77d

Browse files
committed
fix: cache policies
1 parent 09f8b2f commit 65ee77d

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

ayon_server/api/files.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,21 @@ async def handle_download(
128128
)
129129

130130

131-
def image_response_from_bytes(image_bytes: bytes) -> Response:
131+
def image_response_from_bytes(
132+
image_bytes: bytes,
133+
*,
134+
headers: dict[str, str] | None = None,
135+
) -> Response:
132136
media_type = guess_mime_type(image_bytes)
133137
if media_type is None:
134138
raise NotFoundException("Invalid image format")
135139

140+
_headers = {"cache-control": "max-age=3600"}
141+
if headers:
142+
_headers.update(headers)
143+
136144
return Response(
137145
content=image_bytes,
138146
media_type=media_type,
139-
headers={"cache-control": "max-age=3600"},
147+
headers=_headers,
140148
)

ayon_server/helpers/preview.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ async def get_file_preview(
180180
if pvw_bytes == b"":
181181
raise NotFoundException("File preview not available")
182182

183-
return image_response_from_bytes(pvw_bytes)
183+
return image_response_from_bytes(pvw_bytes, headers={"X-File-ID": file_id})
184184

185185

186186
async def uncache_file_preview(project_name: str, file_id: str) -> None:

0 commit comments

Comments
 (0)