Only sweep the cache if cache sweeping is enabled. #245
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When trying to update to
1.2.0
we started getting consist errors in certain system tests that there were pending connections. I ran a bisect onpropshaft
and tracked it down to a change in 689e756 which looks like it may sweep the cache on every request for an asset (introduced in #232). Commenting out the line solved our immediate issue and got our test suite back to green.Digging into this further it looks like cache sweeping would previously only occur when ActionController::Base was loaded and
config.assets.sweep_cache
was true (see here). By defaultsweep_cache
is only set to true in development. But cache sweeping was also being run consistently in our test environment. This appeared to manifest as assets consistently being regenerated which effectively doubled the runtime of our system tests and would cause some pages to take too long to fully render which failed the tests.This pull request adds the same check to the server that
config.assets.sweep_cache
is enabled which was happening in the railtie. I am not sure if this change is compatible with usingpropshaft
without Rails as I don't know if the config is available in that context.Lastly, without this check there is a risk that cache sweeping is occurring in production.