From b0e5a5ccb5cfde8486cfad59185e24e5fb440151 Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Thu, 30 Oct 2025 10:50:28 +0100 Subject: [PATCH] Some fixes for HTTP caching not being invalidated properly --- app/controllers/cards_controller.rb | 2 +- app/controllers/collections/columns/closeds_controller.rb | 2 +- app/controllers/collections/columns/not_nows_controller.rb | 2 +- app/controllers/collections/columns/streams_controller.rb | 2 +- app/controllers/collections/columns_controller.rb | 2 +- app/controllers/concerns/collection_scoped.rb | 4 ++++ app/helpers/cards_helper.rb | 4 ++++ app/views/cards/_container.html.erb | 2 +- 8 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/controllers/cards_controller.rb b/app/controllers/cards_controller.rb index 9cb0b8e52..08de4d806 100644 --- a/app/controllers/cards_controller.rb +++ b/app/controllers/cards_controller.rb @@ -14,7 +14,7 @@ class CardsController < ApplicationController end def show - fresh_when etag: [ @card, @card.collection.columns ] + fresh_when etag: [ @card, @card.collection.columns, @card.collection.name ] end def edit diff --git a/app/controllers/collections/columns/closeds_controller.rb b/app/controllers/collections/columns/closeds_controller.rb index 2ffd7c253..c2c81ae85 100644 --- a/app/controllers/collections/columns/closeds_controller.rb +++ b/app/controllers/collections/columns/closeds_controller.rb @@ -3,6 +3,6 @@ class Collections::Columns::ClosedsController < ApplicationController def show set_page_and_extract_portion_from @collection.cards.closed.recently_closed_first - fresh_when etag: [ @collection, @page.records ] + cards_fresh_when @page.records end end diff --git a/app/controllers/collections/columns/not_nows_controller.rb b/app/controllers/collections/columns/not_nows_controller.rb index 8b6b233b6..3eb4d21c4 100644 --- a/app/controllers/collections/columns/not_nows_controller.rb +++ b/app/controllers/collections/columns/not_nows_controller.rb @@ -3,6 +3,6 @@ class Collections::Columns::NotNowsController < ApplicationController def show set_page_and_extract_portion_from @collection.cards.postponed.reverse_chronologically.with_golden_first - fresh_when etag: [ @collection, @page.records ] + cards_fresh_when @page.records end end diff --git a/app/controllers/collections/columns/streams_controller.rb b/app/controllers/collections/columns/streams_controller.rb index 6ff567c9b..305f0edc6 100644 --- a/app/controllers/collections/columns/streams_controller.rb +++ b/app/controllers/collections/columns/streams_controller.rb @@ -3,6 +3,6 @@ class Collections::Columns::StreamsController < ApplicationController def show set_page_and_extract_portion_from @collection.cards.awaiting_triage.by_last_activity.with_golden_first - fresh_when etag: [ @collection, @page.records ] + cards_fresh_when @page.records end end diff --git a/app/controllers/collections/columns_controller.rb b/app/controllers/collections/columns_controller.rb index 30c5d38fd..7f50a734e 100644 --- a/app/controllers/collections/columns_controller.rb +++ b/app/controllers/collections/columns_controller.rb @@ -5,7 +5,7 @@ class Collections::ColumnsController < ApplicationController def show set_page_and_extract_portion_from @column.cards.active.by_last_activity.with_golden_first - fresh_when etag: [ @column, @page.records ] + cards_fresh_when @page.records end def create diff --git a/app/controllers/concerns/collection_scoped.rb b/app/controllers/concerns/collection_scoped.rb index 2ddde9531..0ca968fbf 100644 --- a/app/controllers/concerns/collection_scoped.rb +++ b/app/controllers/concerns/collection_scoped.rb @@ -9,4 +9,8 @@ module CollectionScoped def set_collection @collection = Current.user.collections.find(params[:collection_id]) end + + def cards_fresh_when(cards) + fresh_when etag: [ cards, @collection.entropy_configuration, @collection.name, Column.all ] + end end diff --git a/app/helpers/cards_helper.rb b/app/helpers/cards_helper.rb index 423478810..1fc89820b 100644 --- a/app/helpers/cards_helper.rb +++ b/app/helpers/cards_helper.rb @@ -50,4 +50,8 @@ module CardsHelper def card_preview_cache_parts(card) [ card, card.collection.entropy_configuration, card.collection.publication, card.collection.name, card.column ] end + + def card_perma_cache_parts(card) + [ card, card.collection.columns, card.collection.name ] + end end diff --git a/app/views/cards/_container.html.erb b/app/views/cards/_container.html.erb index 7ef38603b..b066d2afd 100644 --- a/app/views/cards/_container.html.erb +++ b/app/views/cards/_container.html.erb @@ -1,4 +1,4 @@ -<% cache [ card, card.collection.columns ] do %> +<% cache card_perma_cache_parts(card) do %>
<%= render "cards/container/status", card: card %>