Java Code Examples for javax.ws.rs.core.CacheControl#setNoCache()
The following examples show how to use
javax.ws.rs.core.CacheControl#setNoCache() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CacheControlBuilder.java From everrest with Eclipse Public License 2.0 | 6 votes |
public CacheControl build() { CacheControl cacheControl = new CacheControl(); cacheControl.setMustRevalidate(mustRevalidate); cacheControl.setProxyRevalidate(proxyRevalidate); cacheControl.setMaxAge(maxAge); cacheControl.setSMaxAge(sMaxAge); cacheControl.setNoCache(noCache); cacheControl.setPrivate(privateFlag); cacheControl.setNoTransform(noTransform); cacheControl.setNoStore(noStore); if (privateFields != null) { cacheControl.getPrivateFields().addAll(privateFields); } if (noCacheFields != null) { cacheControl.getNoCacheFields().addAll(noCacheFields); } if (cacheExtension != null) { cacheControl.getCacheExtension().putAll(cacheExtension); } return cacheControl; }
Example 2
Source File: RuleResource.java From localization_nifi with Apache License 2.0 | 5 votes |
private ResponseBuilder noCache(ResponseBuilder response) { CacheControl cacheControl = new CacheControl(); cacheControl.setPrivate(true); cacheControl.setNoCache(true); cacheControl.setNoStore(true); return response.cacheControl(cacheControl); }
Example 3
Source File: CacheControlUtil.java From keycloak with Apache License 2.0 | 5 votes |
public static CacheControl noCache() { CacheControl cacheControl = new CacheControl(); cacheControl.setMustRevalidate(true); cacheControl.setNoCache(true); cacheControl.setNoStore(true); return cacheControl; }
Example 4
Source File: CacheControlUtil.java From keycloak with Apache License 2.0 | 5 votes |
public static CacheControl getDefaultCacheControl() { CacheControl cacheControl = new CacheControl(); cacheControl.setNoTransform(false); Integer maxAge = Config.scope("theme").getInt("staticMaxAge", 2592000); if (maxAge != null && maxAge > 0) { cacheControl.setMaxAge(maxAge); } else { cacheControl.setNoCache(true); } return cacheControl; }
Example 5
Source File: JaxrsSAML2BindingBuilder.java From keycloak with Apache License 2.0 | 5 votes |
private Response response(String redirectUri, boolean asRequest) throws ProcessingException, ConfigurationException, IOException { URI uri = generateURI(redirectUri, asRequest); logger.tracef("redirect-binding uri: %s", uri); CacheControl cacheControl = new CacheControl(); cacheControl.setNoCache(true); return Response.status(302).location(uri) .header("Pragma", "no-cache") .header("Cache-Control", "no-cache, no-store").build(); }
Example 6
Source File: ApplicationResource.java From nifi with Apache License 2.0 | 5 votes |
/** * Edit the response headers to indicating no caching. * * @param response response * @return builder */ protected ResponseBuilder noCache(final ResponseBuilder response) { final CacheControl cacheControl = new CacheControl(); cacheControl.setPrivate(true); cacheControl.setNoCache(true); cacheControl.setNoStore(true); return response.cacheControl(cacheControl); }
Example 7
Source File: RuleResource.java From nifi with Apache License 2.0 | 5 votes |
private ResponseBuilder noCache(ResponseBuilder response) { CacheControl cacheControl = new CacheControl(); cacheControl.setPrivate(true); cacheControl.setNoCache(true); cacheControl.setNoStore(true); return response.cacheControl(cacheControl); }
Example 8
Source File: ProcessorWebUtils.java From nifi with Apache License 2.0 | 5 votes |
static Response.ResponseBuilder applyCacheControl(Response.ResponseBuilder response) { CacheControl cacheControl = new CacheControl(); cacheControl.setPrivate(true); cacheControl.setNoCache(true); cacheControl.setNoStore(true); return response.cacheControl(cacheControl); }
Example 9
Source File: CacheControlHeaderProviderTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testMultipleNoCacheFields() { CacheControl cc = new CacheControl(); cc.setNoCache(true); cc.getNoCacheFields().add("c"); cc.getNoCacheFields().add("d"); assertTrue(cc.toString().contains("no-cache=\"c,d\"")); }
Example 10
Source File: MCRCacheFilter.java From mycore with GNU General Public License v3.0 | 5 votes |
private void addAuthorizationHeaderException(CacheControl cc, boolean isPrivate, boolean isNoCache) { cc.setPrivate(true); if (!cc.getPrivateFields().contains(HttpHeaders.AUTHORIZATION) && !isPrivate) { cc.getPrivateFields().add(HttpHeaders.AUTHORIZATION); } cc.setNoCache(true); if (!cc.getNoCacheFields().contains(HttpHeaders.AUTHORIZATION) && !isNoCache) { cc.getNoCacheFields().add(HttpHeaders.AUTHORIZATION); } }
Example 11
Source File: CacheControlFilter.java From trellis with Apache License 2.0 | 5 votes |
@Override public void filter(final ContainerRequestContext req, final ContainerResponseContext res) { if ((GET.equals(req.getMethod()) || HEAD.equals(req.getMethod())) && SUCCESSFUL.equals(res.getStatusInfo().getFamily()) && maxAge > 0) { final CacheControl cc = new CacheControl(); cc.setMaxAge(maxAge); cc.setMustRevalidate(mustRevalidate); cc.setNoCache(noCache); res.getHeaders().add(CACHE_CONTROL, cc); } }
Example 12
Source File: ApplicationResource.java From nifi-registry with Apache License 2.0 | 5 votes |
/** * Edit the response headers to indicating no caching. * * @param response response * @return builder */ protected Response.ResponseBuilder noCache(final Response.ResponseBuilder response) { final CacheControl cacheControl = new CacheControl(); cacheControl.setPrivate(true); cacheControl.setNoCache(true); cacheControl.setNoStore(true); return response.cacheControl(cacheControl); }
Example 13
Source File: ApplicationResource.java From localization_nifi with Apache License 2.0 | 5 votes |
/** * Edit the response headers to indicating no caching. * * @param response response * @return builder */ protected ResponseBuilder noCache(final ResponseBuilder response) { final CacheControl cacheControl = new CacheControl(); cacheControl.setPrivate(true); cacheControl.setNoCache(true); cacheControl.setNoStore(true); return response.cacheControl(cacheControl); }
Example 14
Source File: ProcessorWebUtils.java From localization_nifi with Apache License 2.0 | 5 votes |
static Response.ResponseBuilder applyCacheControl(Response.ResponseBuilder response) { CacheControl cacheControl = new CacheControl(); cacheControl.setPrivate(true); cacheControl.setNoCache(true); cacheControl.setNoStore(true); return response.cacheControl(cacheControl); }
Example 15
Source File: CacheControlHeaderProviderTest.java From cxf with Apache License 2.0 | 4 votes |
@Test public void testNoCacheDisabled() { CacheControl cc = new CacheControl(); cc.setNoCache(false); assertEquals("no-transform", cc.toString()); }
Example 16
Source File: CacheControlHeaderProviderTest.java From cxf with Apache License 2.0 | 4 votes |
@Test public void testNoCacheEnabled() { CacheControl cc = new CacheControl(); cc.setNoCache(true); assertEquals("no-cache,no-transform", cc.toString()); }
Example 17
Source File: CacheControlHeaderProvider.java From cxf with Apache License 2.0 | 4 votes |
public CacheControl fromString(String c) { boolean isPrivate = false; List<String> privateFields = new ArrayList<>(); boolean noCache = false; List<String> noCacheFields = new ArrayList<>(); boolean noStore = false; boolean noTransform = false; boolean mustRevalidate = false; boolean proxyRevalidate = false; int maxAge = -1; int sMaxAge = -1; Map<String, String> extensions = new HashMap<>(); String[] tokens = getTokens(c); for (String rawToken : tokens) { String token = rawToken.trim(); if (token.startsWith(MAX_AGE)) { maxAge = Integer.parseInt(token.substring(MAX_AGE.length() + 1)); } else if (token.startsWith(SMAX_AGE)) { sMaxAge = Integer.parseInt(token.substring(SMAX_AGE.length() + 1)); } else if (token.startsWith(PUBLIC)) { // ignore } else if (token.startsWith(NO_STORE)) { noStore = true; } else if (token.startsWith(NO_TRANSFORM)) { noTransform = true; } else if (token.startsWith(MUST_REVALIDATE)) { mustRevalidate = true; } else if (token.startsWith(PROXY_REVALIDATE)) { proxyRevalidate = true; } else if (token.startsWith(PRIVATE)) { isPrivate = true; addFields(privateFields, token); } else if (token.startsWith(NO_CACHE)) { noCache = true; addFields(noCacheFields, token); } else { String[] extPair = token.split("="); String value = extPair.length == 2 ? extPair[1] : ""; extensions.put(extPair[0], value); } } CacheControl cc = new CacheControl(); cc.setMaxAge(maxAge); cc.setSMaxAge(sMaxAge); cc.setPrivate(isPrivate); cc.getPrivateFields().addAll(privateFields); cc.setMustRevalidate(mustRevalidate); cc.setProxyRevalidate(proxyRevalidate); cc.setNoCache(noCache); cc.getNoCacheFields().addAll(noCacheFields); cc.setNoStore(noStore); cc.setNoTransform(noTransform); cc.getCacheExtension().putAll(extensions); return cc; }
Example 18
Source File: CacheControlFactory.java From o2oa with GNU Affero General Public License v3.0 | 4 votes |
public static CacheControl getDefault() { CacheControl cc = new CacheControl(); cc.setNoCache(true); return cc; }