Closed codeclout closed 1 year ago
I don't think I'd want this in serverless-iiif core, because it adds complexity to both the code and the deployment in a number of ways.
I know I probably sound like a broken record by now, but a viewer-request
Lambda@Edge function is probably your best bet here, too. You'd could either provision your own source cache bucket, or use the one you already provisioned for >6MB responses, as long as you make sure to avoid naming collisions between cached source images and cached responses.
Extra bonus: It'd solve samvera/node-iiif#25 as well by eliminating the need for the custom HTTP stream resolver.
x-preflight-location
header to the request with the value s3://<cache_bucket>/<path/to/cached/image>
. Might as well set x-preflight-dimensions
too while you're at it.serverless-iiif
do the rest.Set a lifecycle rule on the cache bucket to expire objects on day 1, and you're good to go. Unlimited ephemeral source caching with no changes to the core code.
@mbklein - thank you.
We have implemented this using the Lambda@edge Origin Request
trigger, passing the x-preflight-location
header to the origin and have adopted your recommendations with slight modifications - noted for future readers of this post:
HEAD
request answering if the source image (JP2 in our case) already exists in the S3 bucketno
, then make a request to the HTTP source to retrieve the image
a. If the answer is yes
set the necessary headers and exitx-preflight...
headers to pass to the originUsing the Origin Request
trigger allowed for more flexibility with CPU, processing time and dependencies.
Thanks Again. Brian
Hi,
We have noticed several requests that miss the cache, for example image zoom requests. To mitigate overloading the (HTTP) origin with concurrent lambdas sending zoom requests, we are considering caching the source image at the edge or in memory.
Has the serverless IIIF community considered a local caching scenario to store files retrieved from an external source (jp2), for image viewer processing, to avoid generating dozens of requests to the source for each viewer operation?
Thanks, Brian