I used the following code to redirect from http to https and vice versa
def ensure_proper_protocol
if request.ssl? && !ssl_allowed_action?
redirect_to "http://" + request.host + request.fullpath
elsif !request.ssl? && ssl_allowed_action?
redirect_to "https://" + request.host + request.fullpath
end
end
And removed the gem 'bartt-ssl_requirement'
Still the problem did not go.
Then I simply changed in the production.rb
in the config/environments
config.action_controller.perform_caching = false
Its now working perfectly.