Skip to content

caching: Fully parse and handle request and response cache-control headers#11727

Merged
htuch merged 39 commits intoenvoyproxy:masterfrom
yosrym93:cache-control
Jul 22, 2020
Merged

caching: Fully parse and handle request and response cache-control headers#11727
htuch merged 39 commits intoenvoyproxy:masterfrom
yosrym93:cache-control

Conversation

@yosrym93
Copy link
Copy Markdown
Contributor

@yosrym93 yosrym93 commented Jun 24, 2020

Commit Message: CacheFilter fully parses and handles request and response cache-control headers

Additional Description:
Request and response cache-control headers are fully parsed in CacheHeadersUtils. isCacheableResponse in the CacheFilter now uses parsed cache-control headers to check if a received response can be cached. HttpCache now uses parsed cache-control headers to check if a cached response requires validation before it is served. Cache entries validation is not yet implemented.
Signed-off-by: Yosry Ahmed yosryahmed@google.com

Risk Level: Low
Testing: Unit testing
Docs Changes: N/A
Release Notes: N/A
Fixes #9833

…ponse headers completely

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
yosrym93 added 6 commits June 24, 2020 17:32
…l parsers

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
… headers to find out if a cache entry requires revalidation - revalidation not yet implemented

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
"public" response cache-control directives

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
…eControl structs

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
…imilar class names

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
@yosrym93 yosrym93 changed the title Implemented CacheHeadersParses to parse cache-control request and response headers completely caching: Fully parse and handle request and response cache-control headers Jun 25, 2020
…headers correctly according to RFC7234

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
…t's constructor

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
yosrym93 added 5 commits June 26, 2020 03:03
…r is production-ready

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
…lter) checks for request no-store directives

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
…Utils and HttpCache

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

@toddmgreer I addressed all your comments except those related to CacheHeaderUtils, waiting for further explanation on the private members comment.
Looks like this class will be heavily refactored or removed.

yosrym93 added 3 commits June 26, 2020 16:35
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
…factors to improve readability & Fixed a bug that occurred in SimpleHttpCache tests because LookupRequest did not own the RequestCacheControl object

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
…heHeaderUtils

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
capoferro
capoferro previously approved these changes Jun 26, 2020
…and minimal optimizations

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

@toddmgreer all comments resolved.

@yosrym93
Copy link
Copy Markdown
Contributor Author

/azp run envoy-presubmit

@azure-pipelines
Copy link
Copy Markdown

Commenter does not have sufficient privileges for PR 11727 in repo envoyproxy/envoy

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

/retest

@repokitteh-read-only
Copy link
Copy Markdown

🐴 hold your horses - no failures detected, yet.

🐱

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

see: more, trace.

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
@junr03
Copy link
Copy Markdown
Member

junr03 commented Jul 17, 2020

@yosrym93 do you mind fixing format?

@yosrym93
Copy link
Copy Markdown
Contributor Author

@junr03 It was the legacy codec problem, I merged master, it should be fixed.

@junr03
Copy link
Copy Markdown
Member

junr03 commented Jul 17, 2020

Thanks, @htuch do you mind doing a pass on this (saw that @jmarantz mentioned you a couple times, so thought you could do the senior maintainer pass).

jmarantz
jmarantz previously approved these changes Jul 17, 2020
@jmarantz
Copy link
Copy Markdown
Contributor

Yes, in particular I want @htuch to look at the asserts.

Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Looks great. I'm mostly reviewing this from an Envoy style and safety perspective with the assumption that @jmarantz has the RFC familiarity.
/wait

// Sun, 06 Nov 1994 08:49:37 GMT ; IMF-fixdate
// Sunday, 06-Nov-94 08:49:37 GMT ; obsolete RFC 850 format
// Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format
static const char* rfc7231_date_formats[] = {"%a, %d %b %Y %H:%M:%S GMT",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is GMT an example time zone or compulsory in this datetime format?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This function was originally written by @toddmgreer in source/extensions/filters/http/cache/http_cache_utils.cc , I just moved it to this file. I think he has the answer to this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Compulsory.
See https://httpwg.org/specs/rfc7231.html#http.date, particularly the ABNF grammar.

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM modulo the nit and also bumping up coverage a bit. See https://storage.googleapis.com/envoy-pr/11727/coverage/source/extensions/filters/http/cache/cache_headers_utils.cc.gcov.html (and more generally the cache tree in https://storage.googleapis.com/envoy-pr/11727/coverage/source/extensions/filters/http/cache/index.html). Even debug lines should be exercised somehow.
/wait

@yosrym93
Copy link
Copy Markdown
Contributor Author

yosrym93 commented Jul 22, 2020

@htuch I am fixing the const local variables now. For the coverage, the whole cache tree has low coverage before this PR (still WIP), this PR actually raises coverage by about 4-5% IIRC. I intend to start working on a separate PR to improve coverage & tests generally for this soon.

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
@yosrym93 yosrym93 requested a review from htuch July 22, 2020 00:23
Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! Looking forward to the coverage improvements.

@htuch htuch merged commit b510dd0 into envoyproxy:master Jul 22, 2020
@yosrym93 yosrym93 deleted the cache-control branch July 22, 2020 17:43
KBaichoo pushed a commit to KBaichoo/envoy that referenced this pull request Jul 30, 2020
…aders (envoyproxy#11727)

Request and response cache-control headers are fully parsed in CacheHeadersUtils. isCacheableResponse in the CacheFilter now uses parsed cache-control headers to check if a received response can be cached. HttpCache now uses parsed cache-control headers to check if a cached response requires validation before it is served. Cache entries validation is not yet implemented.
Signed-off-by: Yosry Ahmed yosryahmed@google.com

Risk Level: Low
Testing: Unit testing
Docs Changes: N/A
Release Notes: N/A

Fixes envoyproxy#9833

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: Kevin Baichoo <kbaichoo@google.com>
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: Fully parse and handle request and response cache-control

7 participants