mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
fix favicon caching
This commit is contained in:
@@ -9,11 +9,17 @@ import io.dropwizard.servlets.CacheBustingFilter;
|
|||||||
import io.dropwizard.setup.Bootstrap;
|
import io.dropwizard.setup.Bootstrap;
|
||||||
import io.dropwizard.setup.Environment;
|
import io.dropwizard.setup.Environment;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
import javax.servlet.DispatcherType;
|
import javax.servlet.DispatcherType;
|
||||||
|
import javax.servlet.FilterChain;
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.ServletRequest;
|
||||||
|
import javax.servlet.ServletResponse;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.session.SessionHandler;
|
import org.eclipse.jetty.server.session.SessionHandler;
|
||||||
|
|
||||||
@@ -150,8 +156,18 @@ public class CommaFeedApplication extends Application<CommaFeedConfiguration> {
|
|||||||
swaggerConfig.setBasePath("/rest");
|
swaggerConfig.setBasePath("/rest");
|
||||||
|
|
||||||
// cache configuration
|
// cache configuration
|
||||||
environment.servlets().addFilter("cache-filter", new CacheBustingFilter())
|
// prevent caching on REST resources, except for favicons
|
||||||
.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "/*");
|
environment.servlets().addFilter("cache-filter", new CacheBustingFilter() {
|
||||||
|
@Override
|
||||||
|
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||||
|
String path = ((HttpServletRequest) request).getRequestURI();
|
||||||
|
if (path.contains("/feed/favicon")) {
|
||||||
|
chain.doFilter(request, response);
|
||||||
|
} else {
|
||||||
|
super.doFilter(request, response, chain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "/rest/*");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|||||||
@@ -334,8 +334,7 @@ public class FeedREST {
|
|||||||
|
|
||||||
CacheControl cacheControl = new CacheControl();
|
CacheControl cacheControl = new CacheControl();
|
||||||
cacheControl.setMaxAge(2592000);
|
cacheControl.setMaxAge(2592000);
|
||||||
cacheControl.setPrivate(true);
|
cacheControl.setPrivate(false);
|
||||||
// trying to replicate "public, max-age=2592000"
|
|
||||||
builder.cacheControl(cacheControl);
|
builder.cacheControl(cacheControl);
|
||||||
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
|||||||
Reference in New Issue
Block a user