Package dk.brics.jwig.server.cache

Examples of dk.brics.jwig.server.cache.Cache


            response.setHeader("Connection", "close");
            response.setContentLength(0);
            response.getOutputStream().close();
            return true;
          }
          Cache cache = ThreadContext.getCache();
          StringBuilder updates = new StringBuilder();
          for (int i = 0; i < fragmentnames.length; i++) {
            String name = fragmentnames[i];
            String etag = etags[i];
            Response p = cache.get(name);
            if (p == null || !etag.equals("\"" + p.getETag() + "\""))
              updates.append(name).append(';');
          }
          if (updates.length() > 0) {
            String u = updates.toString();
View Full Code Here


        try {
            ThreadContext.getDependencyMap().beginTransaction(true);
            ThreadContext c = ThreadContext.get();
            HttpServletRequest request = c.getServletRequest();
            HttpServletResponse response = c.getServletResponse();
            Cache cache = ThreadContext.getCache();
            String cacheURL = c.getRequestURL();
            Response cachedResponse = cache.get(cacheURL);
            if (cachedResponse == null) {
                String augmentationString = "<|>"
                        + WebApp.get().getWebSite()
                                .getCacheAugmentationString();
                cacheURL = c.getRequestURL() + augmentationString;
                cachedResponse = cache.get(cacheURL);
            }
            if (cachedResponse != null) {
                String cacheControl = request.getHeader("cache-control");
                long if_modified_since = -1;
                try {
                    if_modified_since = request
                            .getDateHeader("If-Modified-Since");
                } catch (IllegalArgumentException e) {
                    log.info("Client sent invalid If-Modified-Since");
                }
                try {
                    String if_none_match = request.getHeader("If-None-Match");
                    long lastModified = (cachedResponse.getLastModified() / 1000) * 1000;
                    long ifModifiedSince = (if_modified_since / 1000) * 1000;
                    if (if_none_match == null && if_modified_since == -1
                            && cacheControl != null
                            && cacheControl.equals("max-age=0")) {
                        log.info("Client refreshed the page. Removing the old one from the cache");
                        cache.remove(cacheURL);

                    } else {
                        if ((if_none_match != null && if_none_match.equals("\""
                                + cachedResponse.getETag() + "\""))
                                || (if_none_match == null
View Full Code Here

        log.info("Referer: " + referer);
        return referer;
    }

    private Response getReferer(String referer) {
        Cache cache = ThreadContext.getCache();
        Response referer_response = cache.get(referer);
        if (referer_response == null) {
            referer_response = cache.get(referer + "<|>"
                    + getWebSite().getCacheAugmentationString());
        }
        return referer_response;
    }
View Full Code Here

TOP

Related Classes of dk.brics.jwig.server.cache.Cache

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.