Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-940

ResourceHandler sets cache headers regardless of status code

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.0.0.Beta1, 1.4.10.Final
    • None
    • None
    • None

      See the following excerpt from ResourceHandler. It is setting cache headers regardless of whether the resource is found. In my case, I have a next handler that can return a 404 or 500 status, both of which are being cached by some browsers.

      //we set caching headers before we try and serve from the cache
      if (cachable && cacheTime != null) {
      	exchange.getResponseHeaders().put(Headers.CACHE_CONTROL, "public, max-age=" + cacheTime);
      	long date = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(cacheTime);
      	String dateHeader = DateUtils.toDateString(new Date(date));
      	exchange.getResponseHeaders().put(Headers.EXPIRES, dateHeader);
      }
      
      if (cache != null && cachable) {
      	if (cache.tryServeResponse()) {
      		return;
      	}
      }
      

              sdouglas1@redhat.com Stuart Douglas (Inactive)
              blakeday Michael Day (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: