当我以生产模式部署rails应用程序时,它会将日期时间字符串作为查询参数添加到所有静态资源网址的末尾。这是为了防止浏览器在重新部署应用程序后使用资产的旧版本。
When i deploy a rails application in production mode, it appends a date-time string as a query param to the end of all the static asset urls. This is to prevent browsers using old-out of date cahed copies of the assets after I redeploy the application.
有没有办法让栏杆使用旧的时间戳记,用于尚未更改的资产(而仅未更改的资产) )自上次部署以来。我想这样做,以防止用户重新下载那些没有改变的资产。
Is there a way to make rails use the old time stamps for the assets that have not changed (and only the ones that have not changed) since the last deployment. I want to do this to prevent users having to redownload those assets that have not changed.
推荐答案我想你可以使用ENV [ 'RAILS_ASSET_ID']来更改缓存清除资产ID。不幸的是,这是所有资产。
I think you can use ENV['RAILS_ASSET_ID'] to alter the cache-busting asset ID. Unfortunately, this is for all assets.
但是如果没有设置,它将使用资产的源修改时间。如果自上次使用该文件以来,该文件未被修改,则不应该是一个问题。
But if it's not set, it uses the asset's source modification time. If that file hasn't been modified since the last time you used it, it shouldn't be a problem.
如果资产ID没有更改被改变了,可能是因为你的部署过程改变了修改时间,也许你可以看看调整。
If the asset ID is changing when they haven't been changed, it might be because of your deployment process altering the modification time and maybe you could look at tweaking that.
最后,你总是可以使用自己的自定义方法覆盖rails_asset_id 。
希望这有帮助。
更多推荐
删除缓存破坏在Rails生产
发布评论