Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 1208

Show
Ignore:
Timestamp:
08/02/06 23:38:53
Author:
fumanchu
Message:

If not cacheable, we shouldn't even set Expires.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/lib/caching.py

    r1207 r1208  
    180180    If 'force' is False (the default), the following headers are checked: 
    181181    'Etag', 'Last-Modified', 'Age', 'Expires'. If any are already present, 
    182     none of the "cache prevention" headers are set. 
     182    none of the above response headers are set. 
    183183    """ 
    184184     
    185     if isinstance(secs, datetime.timedelta): 
    186         secs = (86400 * secs.days) + secs.seconds 
    187     expiry = http.HTTPDate(cherrypy.response.time + secs) 
    188      
    189     if secs == 0
    190         cacheable = Fals
    191         if not force: 
    192             # some header names that indicate that the response can be cached 
    193             for indicator in ('Etag', 'Last-Modified', 'Age', 'Expires')
    194                 if indicator in cherrypy.response.headers
    195                     cacheable = True 
    196                     break 
    197         if not cacheable
     185    cacheable = False 
     186    if not force: 
     187        # some header names that indicate that the response can be cached 
     188        for indicator in ('Etag', 'Last-Modified', 'Age', 'Expires'): 
     189            if indicator in cherrypy.response.headers
     190                cacheable = Tru
     191                break 
     192     
     193    if not cacheable
     194        if isinstance(secs, datetime.timedelta)
     195            secs = (86400 * secs.days) + secs.seconds 
     196         
     197        if secs == 0
    198198            cptools.response_headers([("Pragma", "no-cache")], force) 
    199199            if cherrypy.request.version >= (1, 1): 
    200200                cptools.response_headers([("Cache-Control", "no-cache")], force) 
    201      
    202     # Set after Pragma, Cache-Control so it doesn't interfere with 'indicators' 
    203     cptools.response_headers([("Expires", expiry)], force) 
     201         
     202        expiry = http.HTTPDate(cherrypy.response.time + secs) 
     203        cptools.response_headers([("Expires", expiry)], force) 

Hosted by WebFaction

Log in as guest/cpguest to create tickets