Use dedicated URLs for accessing file attachment image-based thumbnails.

Review Request #13870 — Created May 20, 2024 and submitted

Information

Review Board
release-7.x

Reviewers

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 associated MimetypeHandler provides image thumbnail
generation support (which ImageMimetype 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.

Summary ID
Use dedicated URLs for accessing file attachment image-based thumbnails.
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 associated `MimetypeHandler` provides image thumbnail generation support (which `ImageMimetype` 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.
659b01aaa0d72b45777cd6f09d95762f693cc06f
Description From Last Updated

I don't actually see any instance variables here.

daviddavid
david
  1. 
      
  2. reviewboard/attachments/mimetypes.py (Diff revision 1)
     
     
     
     
    Show all issues

    I don't actually see any instance variables here.

    1. Oh, used to be one in an earlier revision, which I removed. I'll get rid of this.

  3. 
      
chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-7.x (e8640c7)