Rails 关于 Rails 中 HTTP Cache 的优化

danielglh · 2015年09月01日 · 最后由 danielglh 回复于 2015年09月07日 · 2406 次阅读

各种各样的 cache 技术一直是我们团队用来优化 Strikingly 的用户体验(同时降低服务器压力)的主要手段,最近我们也在整理和充实对这些 cache 技术的理解,有计划写一个系列的博文来总结 Strikingly 后端团队在实践中使用到的 cache 技术,以及一些体会。

这个系列的第一篇博文刚新鲜出炉,欢迎各路大牛批评指正:http://strikingly.github.io/blog/2015/08/31/Optimizing-HTTP-Cache-in-Rails/.

第一个建议(OR 意见):出个中文版的吧 :)

写得很好,有中文版更佳。

#1 楼 @roclv #2 楼 @winnie 好建议,下一篇博文有着落了😄

@danielglh 勘误

if you update any properties of the model that are use visible and should be involved in the revalidation, make sure you use update_attributes , save or save! instead of update_attribute, even if only one property is updated, because update_attribute doesn’t change updated_at
update_attribute(name, value)
Updates a single attribute and saves the record. This is especially useful for boolean flags on existing records. Also note that

Validation is skipped.
Callbacks are invoked.
updated_at/updated_on column is updated if that column is available. # 这行
Updates all the attributes that are dirty in this object.

This method raises an ActiveRecord::ActiveRecordError if the attribute is marked as readonly.

#4 楼 @serco 多谢指点,我印象中一直都是 update_attribute 不会更新 updated_at,可能是记错了。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号