def _cache_rewriter(state):
  # If the response is cacheable, we need to be concerned about the
  # Cache-Control and Expires headers.
  if state.status_code in constants.NO_BODY_RESPONSE_STATUSES:
    return

  if not 'Cache-Control' in state.headers:
    state.headers['Cache-Control'] = 'no-cache'
    if not 'Expires' in state.headers:
      state.headers['Expires'] = 'Fri, 01 Jan 1990 00:00:00 GMT'


  if 'Set-Cookie' in state.headers:
    # 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.
    current_date = time.time()
    expires = state.headers.get('Expires')
    reset_expires = True
    if expires:
      expires_time = email.Utils.parsedate(expires)
      if expires_time:
        reset_expires = calendar.timegm(expires_time) >= current_date
    if reset_expires:
      state.headers['Expires'] = time.strftime('%a, %d %b %Y %H:%M:%S GMT',
                                               time.gmtime(current_date))

    # Remove 'public' cache-control directive, and add 'private' if it (or a
    # more restrictive directive) is not already present.
    cache_directives = []
    for header in state.headers.get_all('Cache-Control'):
      cache_directives.extend(v.strip() for v in header.split(','))
    cache_directives = [d for d in cache_directives if d != 'public']
    if not constants.NON_PUBLIC_CACHE_CONTROLS.intersection(cache_directives):
      cache_directives.append('private')
    state.headers['Cache-Control'] = ', '.join(cache_directives)
Set the default Cache-Control and Expires headers, and sanitize them.
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/tools/devappserver2/request_rewriter.py/_cache_rewriter