Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 210,212c210,216
- < If 'force' is False (the default), the following headers are checked:
- < 'Etag', 'Last-Modified', 'Age', 'Expires'. If any are already present,
- < none of the above response headers are set.
- ---
- > If the response is cacheable (e.g. any of the following response headers exists:
- > 'Etag', 'Last-Modified', 'Age', 'Expires') then the 'Expires' response
- > is set.
- > You can force this behavior (regardless of above condition) by setting Force=True.
- >
- > Setting force to False will keep the tool from overwriting any headers
- > that are already present in the response.
- 217a222
- > # is the response even cacheable?
- 219,224c224,240
- < if not force:
- < # some header names that indicate that the response can be cached
- < for indicator in ('Etag', 'Last-Modified', 'Age', 'Expires'):
- < if indicator in headers:
- < cacheable = True
- < break
- ---
- > # some header names that indicate that the response can be cached
- > for indicator in ('Etag', 'Last-Modified', 'Age', 'Expires'):
- > if indicator in headers:
- > cacheable = True
- > break
- >
- > # perhaps we're supposed to send no-cache headers?
- > no_cache = False
- > # some conditions that indicate that the response should be forcefully no-cached
- > if 'Cache-Control' in headers:
- > cache_control = headers['Cache-Control']
- > if cache_control.startswith('private') or cache_control.startswith('no-cache'):
- > no_cache = True
- > else:
- > pragma = headers['Pragma']
- > if pragma.startswith('no-cache'):
- > no_cache = True
- 226c242
- < if not cacheable:
- ---
- > if cacheable or no_cache or force:
- 230c246,247
- < if secs == 0:
- ---
- > if secs == 0 or no_cache:
- > # do not cache, if possible expire early
- 238a256
- > # otherwise set the expires header
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement