From 40df93eed70a1f48a29adcc86f198b546180b381 Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Mon, 7 Apr 2025 05:10:02 +0200 Subject: [PATCH] Max max age for your own avatar So that you don't get confused when you don't see it update after changing it. --- app/controllers/users/avatars_controller.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/users/avatars_controller.rb b/app/controllers/users/avatars_controller.rb index f700a6825..e48a1f7f2 100644 --- a/app/controllers/users/avatars_controller.rb +++ b/app/controllers/users/avatars_controller.rb @@ -4,7 +4,7 @@ class Users::AvatarsController < ApplicationController before_action :set_user def show - if stale? @user, cache_control: { max_age: 30.minutes, stale_while_revalidate: 1.week } + if stale? @user, cache_control: { max_age: cache_max_age, stale_while_revalidate: 1.week } render_avatar_or_initials end end @@ -15,6 +15,14 @@ class Users::AvatarsController < ApplicationController end private + def cache_max_age + if Current.user == @user + 0 + else + 30.minutes + end + end + def set_user @user = Current.account.users.find(params[:user_id]) end