铁轨6-一段时间后找不到Activestage 404

发布于 2025-02-01 22:48:27 字数 2149 浏览 5 评论 0 原文

一切正常在X天,但随机照片崩溃了...

在视图中,我显示这样的图像:

<%= 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.rb:

 has_one_attached :image_1
 has_one_attached :image_2
 has_one_attached :image_3

contuct.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}"
}

可行,但是... x天后,照片停止显示,没有照片放置了观众的图标。

当它起作用时:

  • 当我在新选项卡中复制图像的URL时 -
  • 当我打开Chrome开发工具(CTRL + Shift + J)和Reload Page时,图像显示 - 照片再次显示

发生了什么?这里有ROR程序员吗? ;)

我没有计算几天,但也许问题在生产中。RB缓存?

找不到404的示例:

https://example.com/rails/active_storage/disk/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdDVG9JYTJWNVNTSWhNbVpzTkdObE1qWjRNRGRxYmpobmNqWnZZakYzY2podFpXSnZad1k2QmtWVU9oQmthWE53YjNOcGRHbHZia2tpUzJsdWJHbHVaVHNnWm1sc1pXNWhiV1U5SWpJMk1UZ3dOemxmTXpneFlpNXFjR2NpT3lCbWFXeGxibUZ0WlNvOVZWUkdMVGduSnpJMk1UZ3dOemxmTXpneFlpNXFjR2NHT3daVU9oRmpiMjUwWlc1MFgzUjVjR1ZKSWc5cGJXRm5aUzlxY0dWbkJqc0dWRG9SYzJWeWRtbGpaVjl1WVcxbE9ncHNiMk5oYkE9PSIsImV4cCI6IjIwMjItMDUtMjhUMDc6MzQ6MzEuNzA2WiIsInB1ciI6ImJsb2Jfa2V5In19--566629b24793a7cca81a263eeb917ecd0d616e72/2618079_381b.jpg

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:

https://example.com/rails/active_storage/disk/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdDVG9JYTJWNVNTSWhNbVpzTkdObE1qWjRNRGRxYmpobmNqWnZZakYzY2podFpXSnZad1k2QmtWVU9oQmthWE53YjNOcGRHbHZia2tpUzJsdWJHbHVaVHNnWm1sc1pXNWhiV1U5SWpJMk1UZ3dOemxmTXpneFlpNXFjR2NpT3lCbWFXeGxibUZ0WlNvOVZWUkdMVGduSnpJMk1UZ3dOemxmTXpneFlpNXFjR2NHT3daVU9oRmpiMjUwWlc1MFgzUjVjR1ZKSWc5cGJXRm5aUzlxY0dWbkJqc0dWRG9SYzJWeWRtbGpaVjl1WVcxbE9ncHNiMk5oYkE9PSIsImV4cCI6IjIwMjItMDUtMjhUMDc6MzQ6MzEuNzA2WiIsInB1ciI6ImJsb2Jfa2V5In19--566629b24793a7cca81a263eeb917ecd0d616e72/2618079_381b.jpg

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

请止步禁区 2025-02-08 22:48:28

如果要为变体的永久性URL,请在 config> config/storage.yml 中添加 public:true
更多在这里

If you want permanent url for your variants, add public: true for your service in config/storage.yml.
More here

删除→记忆 2025-02-08 22:48:28

我认为这是解决方案:

“要生成一个斑点的永久URL,您可以将斑点传递到 url_for 视图助手。这会生成一个带有blob的signed_id的URL,该URL被路由到Blob的RedirectController “

如果没有任何错误,将在几天内看到。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文