solidus_starter_frontend icon indicating copy to clipboard operation
solidus_starter_frontend copied to clipboard

Storefront images disapear

Open magpieuk opened this issue 1 year ago • 6 comments

Images on store front disappear after a while.

Solidus Version:4.4.2

When deployed to production environment with caching enabled, images disappear after a while.

src: image_tag image.url(size), default_options.merge(options)

image_tag url_for(image.attachment.variant(size)), default_options.merge(options)

magpieuk avatar Dec 20 '24 09:12 magpieuk

Hey, could you add some information:

  • are the references to the images disappearing from code or is the image file not served?
  • are you using a CDN or reverse proxy (cloudflare or anything)?
  • are the images still reachable via direct link?
  • are you using any local webserver to reverse proxy such as nginx?

fthobe avatar Dec 20 '24 11:12 fthobe

Image is not being served and appears as a broken link.

.url generates https://hostname/rails/active_storage/disk/##REF##

url_for generates

https://hostname/rails/active_storage/representations/redirect/##REF##

Storage is local to the server using the Disk service.

No proxies are involved. Web server is Apache2/Passenger

magpieuk avatar Dec 20 '24 11:12 magpieuk

The proposed fix (#403) only fixes it when ActiveStorage uses the "local" backend. Most stores use some kind of object storage, like S3, so we need a different fix.

This is an interesting issue, because the usual solution is for the store operator to configure ActiveStorage to generate public URLs, but this is a very common stumbling block. Moving the caching to avoid caching the images is probably a good solution.

jarednorman avatar Jan 08 '25 00:01 jarednorman

@jarednorman can you elaborate what you mean by moving?

fthobe avatar Jan 08 '25 09:01 fthobe

@jarednorman Out of interest why would you not want to use the url_for helper? https://guides.rubyonrails.org/active_storage_overview.html#serving-files suggests this is the correct way to handle them.

magpieuk avatar Jan 08 '25 09:01 magpieuk

@magpieuk Oh, I was mistaken about how that worked. That is probably the right solution. My mistake.

jarednorman avatar Jan 08 '25 21:01 jarednorman