删除缓存破坏在Rails生产 [英] Removing Cache Busting in Rails Production

查看:134
本文介绍了删除缓存破坏在Rails生产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我以生产模式部署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生产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆