diff --git a/app/models/article.rb b/app/models/article.rb index 507421d30..146bd79dd 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -469,6 +469,7 @@ class Article < ApplicationRecord def before_destroy_actions bust_cache + touch_actor_latest_article_updated_at(destroying: true) article_ids = user.article_ids.dup if organization organization.touch(:last_article_at) @@ -659,11 +660,19 @@ class Article < ApplicationRecord self.canonical_url = nil if canonical_url == "" end + def touch_actor_latest_article_updated_at(destroying: false) + return unless destroying || saved_changes.keys.intersection(%w[title cached_tag_list]).present? + + user.touch(:latest_article_updated_at) + organization&.touch(:latest_article_updated_at) + end + def bust_cache EdgeCache::Bust.call(path) EdgeCache::Bust.call("#{path}?i=i") EdgeCache::Bust.call("#{path}?preview=#{password}") async_bust + touch_actor_latest_article_updated_at end def calculate_base_scores diff --git a/app/views/articles/_sticky_nav.html.erb b/app/views/articles/_sticky_nav.html.erb index 76bb7bf23..5045dc1c8 100644 --- a/app/views/articles/_sticky_nav.html.erb +++ b/app/views/articles/_sticky_nav.html.erb @@ -35,7 +35,7 @@ <% end %> - <% cache("article-sticky-nav-articles-0-#{@article.id}-#{@actor.last_article_at}", expires_in: 48.hours) do %> + <% cache("article-sticky-nav-articles-#{@article.id}-#{@actor.latest_article_updated_at}", expires_in: 48.hours) do %> <% if (user_stickies = Articles::GetUserStickies.call(@article, @actor)).present? %>
diff --git a/app/views/articles/show.html.erb b/app/views/articles/show.html.erb index 3811c279f..06b8a991d 100644 --- a/app/views/articles/show.html.erb +++ b/app/views/articles/show.html.erb @@ -206,7 +206,7 @@ - <% cache("article-bottom-content-#{@article.id}-#{user_signed_in?}", expires_in: 18.hours) do %> + <% cache("article-bottom-content-#{@article.id}-#{user_signed_in?}-#{(@organization || @user).latest_article_updated_at}", expires_in: 18.hours) do %> <% suggested_articles = Articles::Suggest.call(@article, max: 4) %> <%= render "articles/bottom_content", articles: suggested_articles %> <% end %> @@ -214,7 +214,7 @@