👍 https://github.com/rails/rails/issues/37555
I did find a few similar issues, but they all got marked as stale https://github.com/rails/rails/issues/34408 https://github.com/rails/rails/issues/31996 https://github.com/rails/rails/issues/34093 I'm surprised this doesn't appear to be a bigger problem. Perhaps I'm not supposed to fragment cache my paginated results. Using collection caching (`render collection: @posts, cached: true`) might be performant enough. On Sunday, October 27, 2019 at 2:55:18 PM UTC+1, richard schneeman wrote: > > Sounds like a bug. Can you move into an issue? > > > > On Thu, Oct 24, 2019 at 7:52 PM Marc Köhlbrugge <h...@marckohlbrugge.com > <javascript:>> wrote: > >> I'm running into a problem when using fragment caching with active record >> collections. >> >> Rails 6 uses a combination of collection.cache_key and >> collection.cache_version to determine whether a fragment cache is fresh or >> not. However, there is a scenario where the collection might change while >> collection.cache_key and collection.cache_version stay the same. >> >> It happens when you use a limit on the collection and then destroy one of >> those records, as long as it's not the most recent one. This way >> collection.cache_key will stay the same, because the query does not change. >> And collection.cache_version will stay the same as well, because the >> collection count will remain unchanged as does the maximum updated_at >> timestamp of the most recent record. >> >> I've build a sample app for demonstration purposes: >> >> https://github.com/marckohlbrugge/rails-6-collection-caching-bug >> >> The readme describes a way to reproduce the issue via the website itself, >> or the Rails console. >> >> Would this be considered a bug or expected behavior? Are there any known >> work arounds? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to rubyonra...@googlegroups.com <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/rubyonrails-core/4cc0ae69-c736-48d0-bd84-8b3f44dc879d%40googlegroups.com >> >> <https://groups.google.com/d/msgid/rubyonrails-core/4cc0ae69-c736-48d0-bd84-8b3f44dc879d%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- > Richard Schneeman > https://www.schneems.com > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/6590103e-3528-4896-bc07-e6ff6a194bef%40googlegroups.com.