Set and use ETag headers
Also set no-cache exactly as github recommends. The removed @no_cache decorater used "Cache-Control:no-cache, no-store, must-revalidate", but just no-cache should be sufficient, and should certainly work correctly with github. See: https://github.com/github/markup/issues/224#issuecomment-48532178 fixes #712
This commit is contained in:
parent
4f6d81b1ec
commit
f4b57eff96
1 changed files with 5 additions and 1 deletions
|
@ -399,7 +399,6 @@ def confirm_recovery():
|
||||||
|
|
||||||
@web.route('/repository/<path:repository>/status', methods=['GET'])
|
@web.route('/repository/<path:repository>/status', methods=['GET'])
|
||||||
@parse_repository_name
|
@parse_repository_name
|
||||||
@no_cache
|
|
||||||
@anon_protect
|
@anon_protect
|
||||||
def build_status_badge(namespace, repository):
|
def build_status_badge(namespace, repository):
|
||||||
token = request.args.get('token', None)
|
token = request.args.get('token', None)
|
||||||
|
@ -423,8 +422,13 @@ def build_status_badge(namespace, repository):
|
||||||
else:
|
else:
|
||||||
status_name = 'none'
|
status_name = 'none'
|
||||||
|
|
||||||
|
if request.headers.get('If-None-Match') == status_name:
|
||||||
|
return Response(status=304)
|
||||||
|
|
||||||
response = make_response(STATUS_TAGS[status_name])
|
response = make_response(STATUS_TAGS[status_name])
|
||||||
response.content_type = 'image/svg+xml'
|
response.content_type = 'image/svg+xml'
|
||||||
|
response.headers['Cache-Control'] = 'no-cache'
|
||||||
|
response.headers['ETag'] = status_name
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in a new issue