Skip to content

caching: Correctly calculate cached responses age#12802

Merged
htuch merged 16 commits intoenvoyproxy:masterfrom
yosrym93:age
Sep 11, 2020
Merged

caching: Correctly calculate cached responses age#12802
htuch merged 16 commits intoenvoyproxy:masterfrom
yosrym93:age

Conversation

@yosrym93
Copy link
Contributor

@yosrym93 yosrym93 commented Aug 24, 2020

Commit Message:
The CacheFilter now correctly calculates the age of cached responses.
Signed-off-by: Yosry Ahmed yosryahmed@google.com

Additional Description:
The time at which responses are received is recorded, and stored with cached responses as response_time. When a response is served from cache, response_time and other headers are used to correctly calculate the age of the cached response.

Risk Level: Low
Testing: Unit tests.
Docs Changes: N/A
Release Notes: N/A
Fixes #9859
Fixes #12140

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
@yosrym93 yosrym93 requested a review from jmarantz as a code owner August 24, 2020 22:41
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
@yosrym93
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines, to retry CircleCI checks, use /retest-circle.
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #12802 (comment) was created by @yosrym93.

see: more, trace.

…er than an internal header

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
@yosrym93 yosrym93 requested a review from toddmgreer August 26, 2020 20:17
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
@yosrym93 yosrym93 requested a review from toddmgreer August 29, 2020 00:05
toddmgreer
toddmgreer previously approved these changes Aug 29, 2020
@yosrym93
Copy link
Contributor Author

yosrym93 commented Sep 1, 2020

@jmarantz I think this is ready for you to take a look!

Copy link
Contributor

@snowp snowp left a comment

Choose a reason for hiding this comment

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

Thanks this looks pretty good to me, just a couple small comments

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
@yosrym93 yosrym93 requested a review from snowp September 3, 2020 18:00
@htuch
Copy link
Member

htuch commented Sep 9, 2020

@snowp @jmarantz any additional feedback or is this good to merge?

Copy link
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

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

basically lgtm with one suggestion to add to a TODO.

size_t stableHashKey(const Key& key);

// The metadata associated with a cached response.
// TODO(yosrym93): This could be changed to a proto if a need arises.
Copy link
Contributor

Choose a reason for hiding this comment

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

for now, yes. However, it's worth noting that if a persistent cache is created using this code, and then you change it to a proto, you'd need to somehow invalidate the entire cache when referenced by the new code.

Maybe add that to the comment? Also how would we invalidate the cache? Would we put a version # into the key?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this to the comment.

As for the how, IIUC, cache invalidation will need to be implemented at some point in the future anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

For the scenario where we need to invalidate everything, we would alter the key generation--if there isn't anything more situation-specific, we might add a version #.

@jmarantz
Copy link
Contributor

jmarantz commented Sep 9, 2020

/wait

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
@yosrym93
Copy link
Contributor Author

yosrym93 commented Sep 9, 2020

@htuch This should be ready to merge now.

@htuch
Copy link
Member

htuch commented Sep 9, 2020

@snowp can you merge if your feedback is now addressed? Thanks.

size_t stableHashKey(const Key& key);

// The metadata associated with a cached response.
// TODO(yosrym93): This could be changed to a proto if a need arises.
Copy link
Contributor

Choose a reason for hiding this comment

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

For the scenario where we need to invalidate everything, we would alter the key generation--if there isn't anything more situation-specific, we might add a version #.

@htuch htuch merged commit 688f8b4 into envoyproxy:master Sep 11, 2020
@yosrym93 yosrym93 deleted the age branch September 11, 2020 01:03
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.

CacheFilter: Add date metadata/ internal header to cached responses CacheFilter: Correctly calculate cached response age

5 participants