If you use ActiveStorage and you have a page with N images you get N additional requests to your Rails app (ie N redirects).
(如果您使用ActiveStorage,并且您的页面中包含N张图片,那么您会向Rails应用程序收到N个其他请求(即N个重定向)。)
That means wasting a lot of server resources if you have tens of images on a page. (如果页面上有几十个图像,这意味着浪费大量服务器资源。)
I know that the redirect is useful for signed URLs.
(我知道重定向对于签名URL很有用。)
However I wonder why Rails does not precompute the final signed URL and embed that into the HTML page... In this way we could keep the advantages of signed URLs / protected files, without making N additional calls to the Rails server. (但是,我想知道为什么Rails不会预先计算最终的签名URL并将其嵌入到HTML页面中...这样,我们可以保留签名URL /受保护文件的优点,而无需对Rails服务器进行N次额外的调用。)
Is it possible to include the final URL / pre-signed URL of image variants directly in the HTML (thus avoiding the redirect)?
(是否可以在HTML中直接包含图像变体的最终URL /预签名URL(从而避免重定向)?)
Otherwise, why is that impossible? (否则,那为什么不可能呢?)
ask by collimarco translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…