-
Notifications
You must be signed in to change notification settings - Fork 36
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
Improve control of resource caching. #69
Labels
Comments
Possible custom cache control if using interceptors: public interface CacheFilterInterceptor {
// the most general one - sometimes cache decision depends on both requests and responses
static ProxyInterceptor cacheIf(BiPredicate<ProxyRequest, ProxyResponse> condition) { // or Predicate<ProxyContext> ?
return null;
}
static ProxyInterceptor notCacheIf(BiPredicate<ProxyRequest, ProxyResponse> condition) {
return null;
}
// some "shortcuts": (necessary?)
static ProxyInterceptor cacheIfHeadersContainOne(List<CharSequence> keys) {
return null;
}
static ProxyInterceptor cacheIfHeadersContainOne(MultiMap headers) {
return null;
}
static ProxyInterceptor cacheIfHeadersContainAll(List<CharSequence> keys) {
return null;
}
static ProxyInterceptor cacheIfHeadersContainAll(MultiMap headers) {
return null;
}
static ProxyInterceptor notCacheIfHeadersContainOne(List<CharSequence> keys) {
return null;
}
static ProxyInterceptor notCacheIfHeadersContainOne(MultiMap headers) {
return null;
}
static ProxyInterceptor notCacheIfHeadersContainAll(List<CharSequence> keys) {
return null;
}
static ProxyInterceptor notCacheIfHeadersContainAll(MultiMap headers) {
return null;
}
static ProxyInterceptor cacheIfPathStartsWith(List<String> paths) {
return null;
}
static ProxyInterceptor notCacheIfPathStartsWith(List<String> paths) {
return null;
}
} Usage: HttpClient client = vertx.createHttpClient();
HttpProxy proxy = HttpProxy.reverseProxy(new ProxyOptions().setCacheOptions(new CacheOptions()), client)
.addInterceptor(CacheFilterInterceptor.cacheIf((req, resp) -> {
return resp.getStatusCode() == 200; // only cache responses if status code is 200
}));
proxy.origin(8081, "localhost"); |
Thanks for sharing findings @wzy1935 Here are a few comments:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We should let users decided (e.g. by providing a set of paths in configuration) which resources shall be cached instead of enabling caching for all resources.
Besides, it should be possible to decide in an interceptor whether a resource is a candidate for caching.
The text was updated successfully, but these errors were encountered: