Use dedicated URLs for accessing file attachment image-based thumbnails.
Review Request #13870 — Created May 20, 2024 and submitted — Latest diff uploaded
We recently introduced a new URL for accessing the contents of a file
attachment, ensuring that cached page responses don't reference URLs
that can expire (such as those from S3). This was done for file
attachments, but not for their thumbnails, which were susceptible to the
same problem.We first noticed a symptom of this issue when moving
https://reviews.reviewboard.org to expiring S3 URLs. Whenever we saved a
caption, we'd see the thumbnail reload. This was happening because we'd
notice the new URL with the new expiration in the metadata and
re-generate the thumbnail information.Now, the download URL can accept a
?thumbnail=1&width=...
query
parameter for accessing the thumbnail image for the attachment. This
requires that the associatedMimetypeHandler
provides image thumbnail
generation support (whichImageMimetype
does).There's a performance advantage here as well. Now, thumbnails are only
generated on demand, when accessing the appropriate download URL. This
means less work when first processing a file attachment, and potentially
fewer things to delete when cleaning up.Since that's faster, we can now reference a @3x thumbnail for images
without taking a performance penalty.
Unit tests passed.
Verified that thumbnails were continuing to work, and that editing
captions was no longer causing a reload.Verified that thumbnail image files were only being generated for the
DPI I was viewing with.