I have rails app that is using this code to generate a resized variant image in the view:
<%= image_tag @user.profile_photo.variant(resize_to_fit: [256, 256]), class: "profile-photo" %>
The image is uploaded directly to S3 using Active Storage and the sample javascript from the Active Storage rails guide.
My problem is that the image reloads on each page load (and flickers). I use the profile photo in the main nav for a user dropdown so it's quite distracting.
How do I cache this? I tried using @user.profile_photo.variant(resize_to_fit: [256, 256]).processed, but the processed method did not fix the flicker either.
Surely this is an issue for many people. What is the correct way to do this? Do I need to call the variant in my controller and then cache it there and just use an instance variable in my view?