Everything works ok for X days but then, something crash for random photos ...
In VIEW I display images like this:
<%= link_to image_tag(f.image_2.variant(resize_to_fill: [30,30]),
:alt => 'x abc' f.username.to_s, loading: "lazy" ),
f.image_2.variant(resize_to_limit: [800,600]),
:class=>'large_photo_box fancybox'
%>
Class has:
has_one_attached :image_1
has_one_attached :image_2
has_one_attached :image_3
Production.rb:
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true
config.cache_store = :file_store, "/tmp/my_cache"
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{10.days.to_i}"
}
It works, but ... after X days the photo stops showing and the no photo icon for the viewer is placed.
When it works:
- when I copy URL for image in new tab - images display
- when I open chrome development tools ( CTRL SHIFT J ) and reload page - the photos display again
What is going on? is there any RoR programmer left in here? ;)
I do not calculate days but maybe problem is in production.rb cache ?
EXAMPLE OF 404 NOT FOUND URL:
CodePudding user response:
If you want permanent url for your variants, add public: true
for your service in config/storage.yml
.
More here
CodePudding user response:
I think that this is solution:
"To generate a permanent URL for a blob, you can pass the blob to the url_for view helper. This generates a URL with the blob's signed_id that is routed to the blob's RedirectController"
Will see in few days if there isn't any errors.