Skip to content

Commit 8c3c547

Browse files
committed
Allow configuring the status codes CacheController tries to cache.
1 parent d338acc commit 8c3c547

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cachecontrol/controller.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,15 +220,16 @@ def conditional_headers(self, request):
220220

221221
return new_headers
222222

223-
def cache_response(self, request, response, body=None):
223+
def cache_response(self, request, response, body=None,
224+
cacheable_status_codes=None):
224225
"""
225226
Algorithm for caching requests.
226227
227228
This assumes a requests Response object.
228229
"""
229230
# From httplib2: Don't cache 206's since we aren't going to
230231
# handle byte range requests
231-
cacheable_status_codes = [200, 203, 300, 301]
232+
cacheable_status_codes = cacheable_status_codes or (200, 203, 300, 301)
232233
if response.status not in cacheable_status_codes:
233234
logger.debug(
234235
'Status code %s not in %s',

0 commit comments

Comments
 (0)