From 315d52961a79a7ec0343142b9bc08ba1bc7b4a03 Mon Sep 17 00:00:00 2001 From: Gaetan Craig-Riou Date: Wed, 21 Jan 2026 14:29:46 +1100 Subject: [PATCH] Add "v1" to locale cache key This is to invalidate existing locale cache key, so it will pick up image path changes in cached fragment with locale --- app/helpers/application_helper.rb | 3 ++- spec/helpers/application_helper_spec.rb | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 343f94332c..36733e26e2 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -72,7 +72,8 @@ module ApplicationHelper end end + # Update "v1" to invalidate existing cache key def cache_key_with_locale(key, locale) - Array.wrap(key) + [locale.to_s, I18nDigests.for_locale(locale)] + Array.wrap(key) + ["v1", locale.to_s, I18nDigests.for_locale(locale)] end end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index fe2679359c..d6d0c61f03 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -89,13 +89,13 @@ RSpec.describe ApplicationHelper do it "appends locale and digest to a single key" do expect( helper.cache_key_with_locale("single-key", "en") - ).to eq(["single-key", "en", en_digest]) + ).to eq(["single-key", "v1", "en", en_digest]) end it "appends locale and digest to multiple keys" do expect( helper.cache_key_with_locale(["array", "of", "keys"], "es") - ).to eq(["array", "of", "keys", "es", es_digest]) + ).to eq(["array", "of", "keys", "v1", "es", es_digest]) end end end