api_dev/src/main/java/com/google/appengine/tools/development/ResponseRewriterFilter.java [255:302]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  private void cacheRewriter(ResponseWrapper response, long responseTime) {
    // If the response has no body, we do not need to be concerned about the
    // Cache-Control and Expires headers.
    if (!responseMayHaveBody(response.getStatus())) {
      return;
    }

    // This differs from production; we do not want caching by default in the
    // development server.
    if (!response.containsHeader(HttpHeaders.CACHE_CONTROL)) {
      response.reallySetHeader(HttpHeaders.CACHE_CONTROL, "no-cache");
      if (!response.containsHeader(HttpHeaders.EXPIRES)) {
        response.reallySetHeader(HttpHeaders.EXPIRES, "Mon, 01 Jan 1990 00:00:00 GMT");
      }
    }

    // This is designed to mimic the behaviour of the GFE as much as possible.
    if (response.containsHeader(HttpHeaders.SET_COOKIE)) {
      // It is a security risk to have any caching with Set-Cookie.
      // If Expires is omitted or set to a future date, and response code is
      // cacheable, set Expires to the current date.
      long expires = response.getExpires();
      if (expires == Long.MIN_VALUE || expires >= responseTime) {
        response.reallySetDateHeader(HttpHeaders.EXPIRES, responseTime);
      }

      // Remove "public" cache-control directive, and add "private" if it (or a
      // more restrictive directive) is not already present.
      Vector<String> cacheDirectives = new Vector<String>(response.getCacheControl());
      while (cacheDirectives.remove("public")) {
        // Iterate until "public" is no longer found in cacheDirectives.
      }
      if (!cacheDirectives.contains("private") && !cacheDirectives.contains("no-cache") &&
          !cacheDirectives.contains("no-store")) {
        cacheDirectives.add("private");
      }
      // Replace Cache-Control with a new single header, with all directives
      // comma-separated.
      StringBuilder newCacheControl = new StringBuilder();
      for (String directive : cacheDirectives) {
        if (newCacheControl.length() > 0) {
          newCacheControl.append(", ");
        }
        newCacheControl.append(directive);
      }
      response.reallySetHeader(HttpHeaders.CACHE_CONTROL, newCacheControl.toString());
    }
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



api_dev/src/main/java/com/google/appengine/tools/development/ee10/ResponseRewriterFilter.java [256:303]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  private void cacheRewriter(ResponseWrapper response, long responseTime) {
    // If the response has no body, we do not need to be concerned about the
    // Cache-Control and Expires headers.
    if (!responseMayHaveBody(response.getStatus())) {
      return;
    }

    // This differs from production; we do not want caching by default in the
    // development server.
    if (!response.containsHeader(HttpHeaders.CACHE_CONTROL)) {
      response.reallySetHeader(HttpHeaders.CACHE_CONTROL, "no-cache");
      if (!response.containsHeader(HttpHeaders.EXPIRES)) {
        response.reallySetHeader(HttpHeaders.EXPIRES, "Mon, 01 Jan 1990 00:00:00 GMT");
      }
    }

    // This is designed to mimic the behaviour of the GFE as much as possible.
    if (response.containsHeader(HttpHeaders.SET_COOKIE)) {
      // It is a security risk to have any caching with Set-Cookie.
      // If Expires is omitted or set to a future date, and response code is
      // cacheable, set Expires to the current date.
      long expires = response.getExpires();
      if (expires == Long.MIN_VALUE || expires >= responseTime) {
        response.reallySetDateHeader(HttpHeaders.EXPIRES, responseTime);
      }

      // Remove "public" cache-control directive, and add "private" if it (or a
      // more restrictive directive) is not already present.
      Vector<String> cacheDirectives = new Vector<String>(response.getCacheControl());
      while (cacheDirectives.remove("public")) {
        // Iterate until "public" is no longer found in cacheDirectives.
      }
      if (!cacheDirectives.contains("private") && !cacheDirectives.contains("no-cache") &&
          !cacheDirectives.contains("no-store")) {
        cacheDirectives.add("private");
      }
      // Replace Cache-Control with a new single header, with all directives
      // comma-separated.
      StringBuilder newCacheControl = new StringBuilder();
      for (String directive : cacheDirectives) {
        if (newCacheControl.length() > 0) {
          newCacheControl.append(", ");
        }
        newCacheControl.append(directive);
      }
      response.reallySetHeader(HttpHeaders.CACHE_CONTROL, newCacheControl.toString());
    }
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



