mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
BUGFIX: mobile ui was being cached for anon views
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
require_dependency "mobile_detection"
|
||||
|
||||
module Middleware
|
||||
class AnonymousCache
|
||||
|
||||
@@ -10,8 +12,19 @@ module Middleware
|
||||
@env = env
|
||||
end
|
||||
|
||||
def is_mobile?
|
||||
@is_mobile ||=
|
||||
begin
|
||||
session = @env["rack.session"]
|
||||
params = ActionDispatch::Request.new(@env).params
|
||||
user_agent = @env["HTTP_USER_AGENT"]
|
||||
|
||||
MobileDetection.resolve_mobile_view!(user_agent,params,session) ? :true : :false
|
||||
end == :true
|
||||
end
|
||||
|
||||
def cache_key
|
||||
@cache_key ||= "ANON_CACHE_#{@env["HTTP_HOST"]}#{@env["REQUEST_URI"]}"
|
||||
@cache_key ||= "ANON_CACHE_#{@env["HTTP_HOST"]}#{@env["REQUEST_URI"]}|m=#{is_mobile?}"
|
||||
end
|
||||
|
||||
def cache_key_body
|
||||
|
||||
Reference in New Issue
Block a user