mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-27 06:46:24 +01:00
* Make host_meta/webfinger replies cacheable (fixes #6100) Drop common code for handling users and sessions as webfinger queries are very basic, public APIs. Also explicitly mark results as cacheable with “expires_in”. * Add “Vary: Accept” header for caching since content-negociation is used
This commit is contained in:
parent
65f30f65a2
commit
868568d1c1
@ -1,15 +1,19 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module WellKnown
|
module WellKnown
|
||||||
class HostMetaController < ApplicationController
|
class HostMetaController < ActionController::Base
|
||||||
include RoutingHelper
|
include RoutingHelper
|
||||||
|
|
||||||
|
before_action { response.headers['Vary'] = 'Accept' }
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@webfinger_template = "#{webfinger_url}?resource={uri}"
|
@webfinger_template = "#{webfinger_url}?resource={uri}"
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.xml { render content_type: 'application/xrd+xml' }
|
format.xml { render content_type: 'application/xrd+xml' }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
expires_in(3.days, public: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module WellKnown
|
module WellKnown
|
||||||
class WebfingerController < ApplicationController
|
class WebfingerController < ActionController::Base
|
||||||
include RoutingHelper
|
include RoutingHelper
|
||||||
|
|
||||||
|
before_action { response.headers['Vary'] = 'Accept' }
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@account = Account.find_local!(username_from_resource)
|
@account = Account.find_local!(username_from_resource)
|
||||||
|
|
||||||
@ -16,6 +18,8 @@ module WellKnown
|
|||||||
render content_type: 'application/xrd+xml'
|
render content_type: 'application/xrd+xml'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
expires_in(3.days, public: true)
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
head 404
|
head 404
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user