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

Add include-http-headers field to cache key policy #265

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class BackendServiceCdnCacheKeyPolicy extends Diffable implements Copyabl
private Boolean includeQueryString;
private List<String> queryStringBlacklist;
private List<String> queryStringWhitelist;
private List<String> includeHttpHeaders;

/**
* If true, requests to different hosts will be cached separately.
Expand Down Expand Up @@ -102,6 +103,22 @@ public void setQueryStringWhitelist(List<String> queryStringWhitelist) {
this.queryStringWhitelist = queryStringWhitelist;
}

/**
* The HTTP request headers (by name) to be used in the cache key.
*/
@Updatable
public List<String> getIncludeHttpHeaders() {
if (includeHttpHeaders == null) {
includeHttpHeaders = new ArrayList<>();
}

return includeHttpHeaders;
}

public void setIncludeHttpHeaders(List<String> includeHttpHeaders) {
this.includeHttpHeaders = includeHttpHeaders;
}

@Override
public String primaryKey() {
return "";
Expand All @@ -123,6 +140,7 @@ public void copyFrom(CacheKeyPolicy model) {

setQueryStringBlacklist(model.getQueryStringBlacklistList());
setQueryStringWhitelist(model.getQueryStringWhitelistList());
setIncludeHttpHeaders(model.getIncludeHttpHeadersList());
}

CacheKeyPolicy toCacheKeyPolicy() {
Expand All @@ -132,6 +150,7 @@ CacheKeyPolicy toCacheKeyPolicy() {
.setIncludeQueryString(TRUE.equals(getIncludeQueryString()))
.addAllQueryStringBlacklist(getQueryStringBlacklist())
.addAllQueryStringWhitelist(getQueryStringWhitelist())
.addAllIncludeHttpHeaders(getIncludeHttpHeaders())
.build();
}
}
Loading