Skip to content

Commit

Permalink
Add caching headers to badge response.
Browse files Browse the repository at this point in the history
Don't want these badges cached, so the most recent status is served
  • Loading branch information
brew committed Feb 6, 2019
1 parent 04bcf96 commit 8a549c8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions datapackage_pipelines/web/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import mistune
import requests

from flask import Blueprint, Flask, render_template, abort, send_file
from flask import \
Blueprint, Flask, render_template, abort, send_file, make_response
from flask_cors import CORS
from flask_jsonpify import jsonify
from flask_basicauth import BasicAuth
Expand Down Expand Up @@ -255,7 +256,11 @@ def _make_badge_response(subject, text, colour):
r = requests.get(image_url)
buffer_image = BytesIO(r.content)
buffer_image.seek(0)
return send_file(buffer_image, mimetype='image/svg+xml')
res = make_response(send_file(buffer_image, mimetype='image/svg+xml'))
res.headers['Cache-Control'] = \
'max-age=0, no-cache, no-store, must-revalidate'
res.headers['Expires'] = '0'
return res


@blueprint.route("badge/<path:pipeline_id>")
Expand Down

0 comments on commit 8a549c8

Please sign in to comment.