feat(image-optimizer): use previously cached image cache entry if upstream image is identical #67257
+223
−39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
getHash
-function to returnbase64url
instead of custom variant of standardbase64
. This can be removed if deemed not necessary.getImageEtag
-function to do it) to happen insideimage-optimizer
for better consistency.Why?
Currently when an image is requested and it becomes stale, the server will trigger a full image optimization for that image, using a significant spike in CPU-usage for routes that have multiple images (e.g. an image carousel).
How?
By calculating and storing the upstream etag in the cache entry, we can utilize the previously cached entry to check if the upstream image has remained the same, making it possible to reuse the previously cached entry again, as the image optimization would produce the same results anyways.