From b3aab1770fc8ee994586296c8367b2cb32c6ec89 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 31 Aug 2018 17:07:31 +1000 Subject: [PATCH] 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. --- app/controllers/user_avatars_controller.rb | 2 +- spec/requests/user_avatars_controller_spec.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/user_avatars_controller.rb b/app/controllers/user_avatars_controller.rb index 271cd412571..39050be70bd 100644 --- a/app/controllers/user_avatars_controller.rb +++ b/app/controllers/user_avatars_controller.rb @@ -173,7 +173,7 @@ class UserAvatarsController < ApplicationController def render_blank path = Rails.root + "public/images/avatar.png" 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 send_file path, disposition: nil end diff --git a/spec/requests/user_avatars_controller_spec.rb b/spec/requests/user_avatars_controller_spec.rb index 73bbfe16cf0..5e8d0e79b09 100644 --- a/spec/requests/user_avatars_controller_spec.rb +++ b/spec/requests/user_avatars_controller_spec.rb @@ -107,7 +107,9 @@ describe UserAvatarsController do get "/user_avatar/default/xxx/51/777.png" 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 it 'serves image even if size missing and its in local mode' do