From 8a8a0c8bfa8b15073207fd757fca6c3ad81d644e Mon Sep 17 00:00:00 2001 From: Heiko Bernloehr Date: Wed, 8 Mar 2017 19:45:39 +0100 Subject: [PATCH] Webcache code (stale?, fresh_when) deleted. --- app/controllers/messages_controller.rb | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index deb01a6..fdf4d60 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -38,6 +38,7 @@ class MessagesController < ApplicationController end def show + # TODO Webcache via stale? and fresh_when @memberships = Membership.receiver(@participant.id, @record.id) case when @record.outtimed_auths_resource_by_non_owner?(@app_namespace, @resource_name, @participant) @@ -56,7 +57,7 @@ class MessagesController < ApplicationController # Create and save a new message. Then render "Created 201" response. - # - todo: exceptions for: create, constantize + # TODO exceptions for: create, constantize def create @record= Message.create__(request, @app_namespace, @ressource_name, @participant) @body = @record.body @@ -237,11 +238,7 @@ protected end unless @memberships.blank? headers["X-EcsReceiverCommunities"]= x_ecs_receiver_communities unless x_ecs_receiver_communities.blank? headers["X-EcsSender"]= x_ecs_sender unless x_ecs_sender.blank? - if stale?(:etag => @record, :last_modified => @record.updated_at.utc, - :x_ecs_receiver_communities => x_ecs_receiver_communities, - :x_ecs_sender => x_ecs_sender) - @render_cmd='render :text => @body, :layout => false, :status => 200, :content_type => Mime::Type.lookup(@record.content_type)' - end + @render_cmd='render :text => @body, :layout => false, :status => 200, :content_type => Mime::Type.lookup(@record.content_type)' end def create_render @@ -269,20 +266,4 @@ protected :content_type => "application/json" end - # this is a custom fresh_when function, which is called by stale? - # see http://www.themomorohoax.com/2009/01/07/using-stale-with-rails-to-return-304-not-modified - def fresh_when(options) - options.assert_valid_keys(:etag, :last_modified, :x_ecs_receiver_communities, :x_ecs_sender) - - response.etag = options[:etag] if options[:etag] - response.last_modified = options[:last_modified] if options[:last_modified] - response.headers["X-EcsReceiverCommunities"] = options[:x_ecs_receiver_communities] unless options[:x_ecs_receiver_communities].blank? - response.headers["X-EcsSender"] = options[:x_ecs_sender] unless options[:x_ecs_sender].blank? - - if request.fresh?(response) - head :not_modified - end - end - - end -- 2.11.4.GIT