Skip to content

Commit

Permalink
Merge pull request #265 from perfectsense/feature/incdule-http-header…
Browse files Browse the repository at this point in the history
…s-for-cache-key-policy

Add include-http-headers field to cache key policy
  • Loading branch information
deepanjan90 authored May 23, 2024
2 parents 2bf776d + 3cdc6fc commit 0095b05
Showing 1 changed file with 19 additions and 0 deletions.
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();
}
}

0 comments on commit 0095b05

Please sign in to comment.