I’m working on a solution on cloudfront where it serves raw image data. This system is configured strangely because it is meant for research and is not a production / professional environment, so I’m making specific decisions in order to facilitate this more smoothly. Even if it is typically not efficient, that is the point of the process.
I’m trying to have my flask app send cloudfront a request for raw image data. It will then take this, read it, display it, and log the time it took from start to finish. The issue I’m running into with this is figuring out how to properly construct the request and structure the architecture around this. I know that Cloudfront caches values from specific headers, but I might need a deeper understanding of Cloudfront in order to fully utilize this.
Right now, I have a rough draft for this system in place.
- Flask button click calls Javascript function, which utilizes fetch() and concats the imagedata to the end of the request.
- Cloudfront caches the value that the header “imgData” sends, improving performance speed.
I know it is likely not to work, however, as sending that much data is unwieldy and unlikely to improve performance. I’m just struggling to design this in a more efficient way.
I believe the way it should work is
- Flask calls cloudfront distribution to retrieve imgdata
- cloudfront doesnt have it, a cache miss
3)Reroutes request to flask app, which then handles serving the image - cloudfront caches image data for next request
However, I’m having a hard time implementing this as I don’t understand how cloudfront reroutes the request from step 2 to 3, nor how it caches this data.