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
This commit is contained in:
Gaetan Craig-Riou
2026-01-21 14:29:46 +11:00
parent 90f962a886
commit 315d52961a
2 changed files with 4 additions and 3 deletions

View File

@@ -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

View File

@@ -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