'Why all SQL queries from a Rails action are being cached after refreshing an ActiveAdmin page 3 times?
I've experienced a very strange behaviour with a really simple show page of a Rails project with ActiveAdmin.
When I first load my show#Projects page on ActiveAdmin, the correct project data is displayed on the page and the logs are ok (no sql queries are being cached)
After 3 manual page reload, the displayed data is outdated, and the logs show that all SQL queries use cache !
How is it possible ?
I have the most basic cache config ever :
- no use of manual cache in code at all
- I only have the default config
config.action_controller.perform_caching = truein config/production.rb, that use the default caching store (FileStore)
Even stranger, if I change perform_caching config to false, the problem remains exactly the same !
Does someone would be able to tell me where this cache is coming from and how I can disable it ?
Thanks a lot!
Solution 1:[1]
I found my solution !
My problem was that all SQL queries were being cached from the beginning of an action and they should not.
In theory, with SQL Query caching, query caches are created at the start of an action and destroyed at the end of that action and thus persist only for the duration of the action.
For some reason, in Rails 6.0.4.4, this was bugged because :
Under certain circumstances, the middleware isn't informed that the response body has been fully closed which result in request state not being fully reset before the next request
This was fixed by 6.0.4.5 with this commit.
It's now working as expected !
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | emilie |

