I really liked the idea to do HTTP Cache only passing a resource and the plugin automatically extract the fields updated_at or updated_on from it!
So I've inserted this functionality into Easy HTTP Cache plugin also. You just need to do:
class ListsController < ApplicationController
http_cache :index, :show, :last_change_at => :list
protected
def list
@list ||= List.find(params[:id])
end
endThis will automatically expire the cache if the object was updated after the client requested the page for the last time! It works calling the method :list and then calling updated_at or updated_on on the object returned by the method.
Get it on GitHub here!
And check Restfully Yours plugin also, because it's more than HTTP Cache and adds some nice features to Your REST application! It treats HTTP Cache differently (it's inside Your action) and allows Conditional PUT!



0 comentários:
Postar um comentário