Skip to content
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

Performance and code optimization in HTTP cache #496

Merged
merged 5 commits into from
Oct 24, 2023

Conversation

ok2c
Copy link
Member

@ok2c ok2c commented Oct 21, 2023

Caching code optimization

  • Moved delta-second parsing routine to CacheSupport
  • Optimized ResponseCachingPolicy#isResponseCacheable by parsing response DATE and EXPIRES headers only once
  • HttpCacheEntry to cache parsed DATE, EXPIRES and LAST_MODIFIED values
  • HttpCacheEntry to avoid parsing DATE header of cache entries and HTTP messages multiple times
  • Eliminated dependency on impl classes in public API classes

@ok2c
Copy link
Member Author

ok2c commented Oct 21, 2023

@arturobernalg Please take a look.

…; avoid parsing DATE header of cache entries and HTTP messages multiple times
Copy link
Member

@arturobernalg arturobernalg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ok2c The change-set looks good. Just a small comment.

@@ -258,7 +253,7 @@ protected boolean isExplicitlyNonCacheable(final ResponseCacheControl cacheContr
}

protected boolean isExplicitlyCacheable(final ResponseCacheControl cacheControl, final HttpResponse response) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're calling isExplicitlyCacheable twice within the isResponseCacheable method. Maybe we could storing its result in a variable and reusing it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're calling isExplicitlyCacheable twice within the isResponseCacheable method. Maybe we could storing its result in a variable and reusing it.

@arturobernalg True. However, It is relatively cheap and the first invocation gets executed conditionally. I think It is not worth the ugliness of having an extra parameter to pass around.

@ok2c ok2c merged commit 1435869 into apache:5.4.x Oct 24, 2023
7 checks passed
@ok2c ok2c deleted the HTTPCLIENT-2277 branch October 24, 2023 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants