Merge pull request #799 from mjibson/status-badge-cache

Set and use ETag headers on status badges
This commit is contained in:
Matt Jibson 2015-11-06 12:15:35 -05:00
commit 576fcf5325

View file

@ -399,7 +399,6 @@ def confirm_recovery():
@web.route('/repository/<path:repository>/status', methods=['GET'])
@parse_repository_name
@no_cache
@anon_protect
def build_status_badge(namespace, repository):
token = request.args.get('token', None)
@ -423,8 +422,13 @@ def build_status_badge(namespace, repository):
else:
status_name = 'none'
if request.headers.get('If-None-Match') == status_name:
return Response(status=304)
response = make_response(STATUS_TAGS[status_name])
response.content_type = 'image/svg+xml'
response.headers['Cache-Control'] = 'no-cache'
response.headers['ETag'] = status_name
return response