FIX: set old last modified date for invalid avatars

In some cases Akami was holding tight to these invalid avatars,
to avoid this happening we explain the avatar image is ancient
then when a new upload is added it automatically is older than
this.
This commit is contained in:
Sam 2018-08-31 17:07:31 +10:00
parent 1866a8e8da
commit b3aab1770f
2 changed files with 4 additions and 2 deletions

View File

@ -173,7 +173,7 @@ class UserAvatarsController < ApplicationController
def render_blank def render_blank
path = Rails.root + "public/images/avatar.png" path = Rails.root + "public/images/avatar.png"
expires_in 10.minutes, public: true expires_in 10.minutes, public: true
response.headers["Last-Modified"] = 10.minutes.ago.httpdate response.headers["Last-Modified"] = Time.new('1990-01-01').httpdate
response.headers["Content-Length"] = File.size(path).to_s response.headers["Content-Length"] = File.size(path).to_s
send_file path, disposition: nil send_file path, disposition: nil
end end

View File

@ -107,7 +107,9 @@ describe UserAvatarsController do
get "/user_avatar/default/xxx/51/777.png" get "/user_avatar/default/xxx/51/777.png"
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(response.headers["Last-Modified"]).to eq(10.minutes.ago.httpdate)
# this image should be really old so when it is fixed various algorithms pick it up
expect(response.headers["Last-Modified"]).to eq(Time.new('1990-01-01').httpdate)
end end
it 'serves image even if size missing and its in local mode' do it 'serves image even if size missing and its in local mode' do