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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user