Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package io.undertow.server.handlers;
 
 import java.util.Map;
 import java.util.Set;
 
Handler that disables response caching by browsers and proxies.

Author(s):
Stuart Douglas
public class DisableCacheHandler implements HttpHandler {
    private final HttpHandler next;
    public DisableCacheHandler(HttpHandler next) {
        this. = next;
    }
    @Override
    public void handleRequest(HttpServerExchange exchangethrows Exception {
        exchange.getResponseHeaders().add(."no-cache, no-store, must-revalidate");
        exchange.getResponseHeaders().add(."no-cache");
        exchange.getResponseHeaders().add(."0");
        .handleRequest(exchange);
    }
    public static class Builder implements HandlerBuilder {
        @Override
        public String name() {
            return "disable-cache";
        }
        @Override
        public Map<StringClass<?>> parameters() {
            return Collections.emptyMap();
        }
        @Override
        public Set<StringrequiredParameters() {
            return Collections.emptySet();
        }
        @Override
        public String defaultParameter() {
            return null;
        }
        @Override
        public HandlerWrapper build(Map<StringObjectconfig) {
            return new Wrapper();
        }
    }
    private static class Wrapper implements HandlerWrapper {
        @Override
        public HttpHandler wrap(HttpHandler handler) {
            return new DisableCacheHandler(handler);
        }
    }
New to GrepCode? Check out our FAQ X