-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Manage caching options: EnableHeadersHashing
vs CleanableHashingRegexes
#2233
base: develop
Are you sure you want to change the base?
Conversation
Let me briefly explain the changes: When EnableHeadersHashing is enabled, it reads the request headers and adds them to the cache key. However, the parameters in the request headers include unique GUIDs every time. A different example of this issue is when a proxy like CloudFlare is used. These setups can also add their own header parameters with each request. To resolve such situations, CleanableHashingRegexes can be used as an additional solution. Perhaps, on the Ocelot side, a default regex pattern could be added to CleanableHashingRegexes to remove parameter GUIDs. Similarly, the same solution could include a default regex pattern for CloudFlare. Regex pattern for solving the parameter GUID issue: public CacheOptions(int? ttlSeconds, string region, string header, bool? enableContentHashing, bool? enableHeadersHashing, List<string>? cleanableHashingRegexes)
{
TtlSeconds = ttlSeconds ?? 0;
Region = region;
Header = header;
EnableContentHashing = enableContentHashing ?? false;
EnableHeadersHashing = enableHeadersHashing ?? false;
CleanableHashingRegexes = cleanableHashingRegexes ?? new()
{
"cf-ray=[a-f0-9]{16}-[A-Z]{1,3}" //CloudFlare CF-RAY
"--[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}--|(--[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})" //GUID of Parameters
};
} |
What's your real full name? P.S.Thank you for creation the PR without fake changes. The PR has no EOL issues now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my brief opinion, you are suggesting a new feature for caching. On the other hand, our team views the CacheManager as an outdated Ocelot extension package, and we plan to discontinue support by archiving the project soon:
- See 23.4.2 Release Notes → Warning → Item 5
However, it appears your pull request pertains only to the core Caching feature, which is positive.
$\color{red}{No\ Acceptance\ and\ Unit\ tests!}$
Please include tests. See both Ocelot.AcceptanceTests and Ocelot.UnitTests projects.
Please note that updating old tests is must-have, you did it, but our Dev Process requires to write new tests for the new feature!
$\color{orange}{Documentation\ Update\ Required!}$
The sources for our documentation can be found here: docs
In particular, you must update the feature document: caching.rst
P.S. It is essential to be familiar with our Development Process.
New Feature: EnableHeadersHashing & CleanableHashingRegexes
This pull request introduces several enhancements to the caching mechanism by adding new configuration options and updating related tests. The main changes include the addition of headers hashing, cleanable hashing regexes, and their integration into the existing caching logic.
Hashing Behavior Configuration
If
EnableContentHashing
is set toFalse
andEnableHeadersHashing
is set toFalse
:CleanableHashingRegexes
is it doesnt make a difference.If
EnableContentHashing
is set toTrue
andEnableHeadersHashing
is set toFalse
:CleanableHashingRegexes
is not using. If used it will work.If
EnableContentHashing
is set toTrue
andEnableHeadersHashing
is set toTrue
:CleanableHashingRegexes
is using. If its not used it will not work.Example Usings
2024-12-05_12-09-34.False-False.mp4
2024-12-05_12-11-11.True-False.mp4
2024-12-05_12-13-13.True-True.mp4