New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate automatic cache invalidation in Request#{GET,POST} #2073
base: main
Are you sure you want to change the base?
Deprecate automatic cache invalidation in Request#{GET,POST} #2073
Conversation
Add Request#clear_{GET,POST} for users to perform manual cache invalidation when replacing env['QUERY_STRING'] or env['rack.input']. With this invalidation, env[RACK_REQUEST_QUERY_STRING] and env[RACK_REQUEST_FORM_INPUT] are unnecessary. It appears as though env[RACK_REQUEST_FORM_VARS] is already unnecessary, as the value is set but never accessed, dating back to its introduction in 6c80c6c. However, even though it is never used by Rack, it apparently is used by Rails. However, Rails usage appears to be limited to parameter filtering, and if the RACK_REQUEST_FORM_VARS key wasn't set, there would be nothing to filter. So it's possible Rails could be changed so that if the key was missing, there are no problems (maybe it works like that already, and only the Rails tests need updates).
What is the expected use case of |
The expected use case is if you modify Certainly creating a new clean |
Right but we can remove the automatic cache invalidation without introducing manual cache invalidation? |
Certainly it is possible. Introducing manual cache invalidation allows the user currently relying on automatic cache invalidation to more easily update their code. Removing automatic cache invalidation without introducing manual cache invalidation leaves it to the user to figure out how to perform the manual cache invalidation themselves. |
Another option is to provide a blessed way to assign the query part of the URL, e.g. |
FWIW, I continue to insist that this is inherently a "no longer Rack" level of API breakage, because it assumes everyone is accessing If we're willing to switch to a model where the Request object is the source of truth, caching becomes trivial. But as long as everyone is potentially building their own instance and Request is merely a convenience accessor to the true live values in Extending the spec with a series of "if you modify key 'x' in At least moving the cache to ivars would mean that a given Request is the extent of the confusion -- and can be more internally responsible. With the current arrangement of caching to (Emphasis that this is my opinion of the situation we're stuck in by virtue of Rack's fundamentally hash-based API, not a personal preference for said arrangement.) |
My understanding is @tenderlove, @ioquatix, and I all want to remove the automatic cache invalidation. If a user modifies This PR tries to be a little nicer and give This is unrelated to This deliberately doesn't document if you change The issue with moving the cache to ivars is that by design, separate @tenderlove @ioquatix Can you provide your feedback on whether we should offer manual cache invalidation (as this PR does), or just remove the automatic cache invalidation and tell users they are on their own if they modify |
My concern is here:
|
To me, whether the modification is done directly by the user's code or indirectly by some other code the user is choosing to run does not matter. Maybe @tenderlove or @ioquatix feels differently? |
Add Request#clear_{GET,POST} for users to perform manual cache invalidation when replacing env['QUERY_STRING'] or env['rack.input'].
With this invalidation, env[RACK_REQUEST_QUERY_STRING] and env[RACK_REQUEST_FORM_INPUT] are unnecessary.
It appears as though env[RACK_REQUEST_FORM_VARS] is already unnecessary, as the value is set but never accessed, dating back to its introduction in 6c80c6c. However, even though it is never used by Rack, it apparently is used by Rails. However, Rails usage appears to be limited to parameter filtering, and if the RACK_REQUEST_FORM_VARS key wasn't set, there would be nothing to filter. So it's possible Rails could be changed so that if the key was missing, there are no problems (maybe it works like that already, and only the Rails tests need updates).
Request#clear_{GET,POST} are pretty ugly as far as method naming goes, but so are Request#{GET,POST}, so it kind of fits. Open to better suggestions for names.