Disable that pesky browser cache in the ways that matter.

This commit is contained in:
jakedt 2014-03-26 18:36:59 -04:00
parent 95dcf58b90
commit 910fabe103
3 changed files with 14 additions and 7 deletions

View file

@ -1,10 +1,12 @@
import logging
import urlparse
import json
import string
from flask import make_response, render_template, request
from flask.ext.login import login_user, UserMixin
from flask.ext.principal import identity_changed
from random import SystemRandom
from data import model
from data.queue import dockerfile_build_queue
@ -83,8 +85,13 @@ def handle_dme(ex):
return make_response(json.dumps({'message': ex.message}), 400)
def random_string():
random = SystemRandom()
return ''.join([random.choice(string.ascii_uppercase + string.digits) for _ in range(8)])
def render_page_template(name, **kwargs):
resp = make_response(render_template(name, route_data=json.dumps(get_route_data()), **kwargs))
resp = make_response(render_template(name, route_data=json.dumps(get_route_data()),
cache_buster=random_string(), **kwargs))
resp.headers['X-FRAME-OPTIONS'] = 'DENY'
return resp

View file

@ -17,7 +17,7 @@
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.no-icons.min.css">
<link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="/static/css/quay.css">
<link rel="stylesheet" href="/static/css/quay.css?v={{ cache_buster }}">
<link rel="stylesheet" href="/static/lib/angular-motion.min.css">
<link rel="stylesheet" href="/static/lib/bootstrap-additions.min.css">
@ -76,10 +76,10 @@
window.__token = '{{ csrf_token() }}';
</script>
<script src="/static/js/tour.js"></script>
<script src="/static/js/app.js"></script>
<script src="/static/js/controllers.js"></script>
<script src="/static/js/graphing.js"></script>
<script src="/static/js/tour.js?v={{ cache_buster }}"></script>
<script src="/static/js/app.js?v={{ cache_buster }}"></script>
<script src="/static/js/controllers.js?v={{ cache_buster }}"></script>
<script src="/static/js/graphing.js?v={{ cache_buster }}"></script>
<!-- start Mixpanel --><script type="text/javascript">
var isProd = document.location.hostname === 'quay.io';

View file

@ -29,6 +29,6 @@ def no_cache(f):
@wraps(f)
def add_no_cache(*args, **kwargs):
response = f(*args, **kwargs)
response.headers['Cache-Control'] = 'no-cache'
response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
return response
return add_no_cache