是否可以stale?与集合一起使用?例如,我正在开发一个REST api,它允许客户端偶尔查询服务器以询问最新的项目列表.如果stale?能够针对我的If-Modified ..标头检查集合并且如果没有任何变化则发送304 将是很好的.
快速举例:
def index
@items = Item.all
if stale?(@items)
render json: @items
end
end
def show
if stale?(@item)
render json: @item
end
end
Run Code Online (Sandbox Code Playgroud)