fastapi-cache icon indicating copy to clipboard operation
fastapi-cache copied to clipboard

Caching not convertible to JSON eg. image/png response type

Open Martenz opened this issue 10 months ago • 3 comments

Would it be possible to cache images with byte response type? If so how? with a custom encoder?

eg with image_tile -> bytes:

`@router.get("/{cog_name}/{z}/{x}/{y}") async def get_cog_tile(cog_name: str, z: int, x: int, y: int, colormap: str = 'terrain') -> Response:

...

headers = {"Content-Encoding": "identity", "content-type": 'image/png'} return Response(content=image_tile, headers=headers) `

Thanks

Martenz avatar Aug 23 '23 14:08 Martenz