Storefront images disapear
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)
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?
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
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 can you elaborate what you mean by moving?
@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 Oh, I was mistaken about how that worked. That is probably the right solution. My mistake.