Don't let cloudflare cache avatars

The issue here is that anyone else who views my avatar will cause it
to be cached, and then I can't easily bust the cache if I change my
avatar.
This commit is contained in:
Mike Dalessio
2025-11-22 09:40:27 -05:00
parent 03e24b0ffa
commit 4dc28943da
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ class Users::AvatarsController < ApplicationController
if @user == Current.user
{}
else
{ max_age: 30.minutes, stale_while_revalidate: 1.week, public: true }
{ max_age: 30.minutes, stale_while_revalidate: 1.week }
end
end
@@ -15,7 +15,7 @@ class Users::AvatarsControllerTest < ActionDispatch::IntegrationTest
test "show other initials with caching" do
get user_avatar_path(users(:kevin))
assert_match "image/svg+xml", @response.content_type
assert @response.cache_control[:public]
assert @response.cache_control[:private]
assert_equal 30.minutes.to_s, @response.cache_control[:max_age]
end