SHARE
TWEET

Jae Kwon

a guest Jul 31st, 2009 31 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 210,212c210,216
  2. <     If 'force' is False (the default), the following headers are checked:
  3. <     'Etag', 'Last-Modified', 'Age', 'Expires'. If any are already present,
  4. <     none of the above response headers are set.
  5. ---
  6. >     If the response is cacheable (e.g. any of the following response headers exists:
  7. >        'Etag', 'Last-Modified', 'Age', 'Expires') then the 'Expires' response
  8. >        is set.
  9. >     You can force this behavior (regardless of above condition) by setting Force=True.
  10. >
  11. >     Setting force to False will keep the tool from overwriting any headers
  12. >     that are already present in the response.
  13. 217a222
  14. >     # is the response even cacheable?
  15. 219,224c224,240
  16. <     if not force:
  17. <         # some header names that indicate that the response can be cached
  18. <         for indicator in ('Etag', 'Last-Modified', 'Age', 'Expires'):
  19. <             if indicator in headers:
  20. <                 cacheable = True
  21. <                 break
  22. ---
  23. >     # some header names that indicate that the response can be cached
  24. >     for indicator in ('Etag', 'Last-Modified', 'Age', 'Expires'):
  25. >         if indicator in headers:
  26. >             cacheable = True
  27. >             break
  28. >    
  29. >     # perhaps we're supposed to send no-cache headers?
  30. >     no_cache = False
  31. >     # some conditions that indicate that the response should be forcefully no-cached
  32. >     if 'Cache-Control' in headers:
  33. >         cache_control = headers['Cache-Control']
  34. >         if cache_control.startswith('private') or cache_control.startswith('no-cache'):
  35. >             no_cache = True
  36. >         else:
  37. >             pragma = headers['Pragma']
  38. >             if pragma.startswith('no-cache'):
  39. >                 no_cache = True
  40. 226c242
  41. <     if not cacheable:
  42. ---
  43. >     if cacheable or no_cache or force:
  44. 230c246,247
  45. <         if secs == 0:
  46. ---
  47. >         if secs == 0 or no_cache:
  48. >             # do not cache, if possible expire early
  49. 238a256
  50. >             # otherwise set the expires header
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top