Skip to content

Add option for set cache policy based on cookie name or pattern #1564

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

Merged
merged 5 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Module.symvers
.settings
.pydevproject

# vscode project settings
.vscode

# Python compiler cache files
*.pyc

Expand Down
1 change: 1 addition & 0 deletions fw/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ tfw_cache_employ_req(TfwHttpReq *req)
/* cache_fulfill - work as usual in cache mode. */
BUG_ON(cmd != TFW_D_CACHE_FULFILL);

/* CC_NO_CACHE also may be set by http chain rules */
if (req->cache_ctl.flags & TFW_HTTP_CC_NO_CACHE)
/*
* TODO: RFC 7234 4. "... a cache MUST NOT reuse a stored
Expand Down
10 changes: 9 additions & 1 deletion fw/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -4010,7 +4010,7 @@ tfw_http_hdr_split(TfwStr *hdr, TfwStr *name_out, TfwStr *val_out, bool inplace)

val_out->len += chunk->len;

/*
/*
* Skip OWS after the header value (RWS) - they must be in
* separate chunks too.
*/
Expand Down Expand Up @@ -5402,6 +5402,14 @@ tfw_http_req_process(TfwConn *conn, TfwStream *stream, const TfwFsmData *data)
*/
req->cache_ctl.timestamp = tfw_current_timestamp();
req->jrxtstamp = jiffies;
/*
* Bypass cache if corresponding binary flag in request set.
* We need separate from cache_ctl binary flag in request
* due to multiple rules may one after one set and clear
* the flag before it evaluated to CC_NO_CACHE here.
*/
if (unlikely(test_bit(TFW_HTTP_B_CHAIN_NO_CACHE, req->flags)))
req->cache_ctl.flags |= TFW_HTTP_CC_NO_CACHE;

/*
* Run frang checks first before any processing happen. Can't start
Expand Down
2 changes: 2 additions & 0 deletions fw/http.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ enum {
TFW_HTTP_FLAGS_REQ,
/* Sticky cookie is found and verified. */
TFW_HTTP_B_HAS_STICKY = TFW_HTTP_FLAGS_REQ,
/* Request fitted no cache cookie rule */
TFW_HTTP_B_CHAIN_NO_CACHE,
/* Request is non-idempotent. */
TFW_HTTP_B_NON_IDEMP,
/* Request stated 'Accept: text/html' header */
Expand Down
Loading