From 306f2ed72340b5ad19d5a02701b4057c433b6948 Mon Sep 17 00:00:00 2001 From: Carlos Vieira Date: Mon, 12 May 2014 15:10:43 -0300 Subject: [PATCH] barrabrasil.py: recolocado o etag. Adicionado data de modifica??o pelo build. profile e build.sh: adicionando campo com data de modifica??o. --- app/barrabrasil.py | 22 +++++++++++++--------- app/profile | 1 + build.sh | 1 + 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/barrabrasil.py b/app/barrabrasil.py index cd39f57..c73c68c 100644 --- a/app/barrabrasil.py +++ b/app/barrabrasil.py @@ -38,28 +38,32 @@ def barra(): f = app.open_resource('profile') cfg = Config(f) profile = cfg.profile + data = cfg.date with app.open_resource('templates/%s/barra-brasil.js' % profile) as f: conteudo = f.read().decode('utf-8') - #etag = hashlib.sha1(conteudo.encode('utf-8')).hexdigest() - #if request.if_none_match and \ - # etag in request.if_none_match: - # resposta = Response(status=304) - #else: # nao esta em cache do navegador - resposta = make_response(conteudo) - # resposta.set_etag(etag) + etag = hashlib.sha1(conteudo.encode('utf-8')).hexdigest() + if request.if_none_match and \ + etag in request.if_none_match: + resposta = Response(status=304) + else: # nao esta em cache do navegador + resposta = make_response(conteudo) + resposta.set_etag(etag) resposta.headers['Content-type'] = 'application/x-javascript' resposta.headers['Cache-control'] = 'public, max-age: 86400' #24 horas - resposta.headers['Last-Modified'] = 'Mon, 30 Sep 2013 19:08:30 GMT' + resposta.headers['Last-Modified'] = data return resposta @app.route('/static/opensans-bold.woff') def fonte(): + f = app.open_resource('profile') + cfg = Config(f) + data = cfg.date f = app.open_resource('static/opensans-bold.woff') conteudo = f.read().decode('base64') resposta = make_response(conteudo) resposta.headers['Content-type'] = 'application/x-font-woff' resposta.headers['Cache-control'] = 'public, max-age: 86400' #24 horas - resposta.headers['Last-Modified'] = 'Mon, 30 Sep 2013 19:08:30 GMT' + resposta.headers['Last-Modified'] = data return resposta if __name__ == '__main__': diff --git a/app/profile b/app/profile index b33cf13..92996e5 100644 --- a/app/profile +++ b/app/profile @@ -1 +1,2 @@ profile : copa2014 +date : " Mon, 12 May 2014 15:04:36 -0300 " diff --git a/build.sh b/build.sh index 9ed5886..9bc4526 100755 --- a/build.sh +++ b/build.sh @@ -14,6 +14,7 @@ then cd ../../app touch profile echo 'profile :' $profile > profile + echo 'date : "' $(date -R) '"'>> profile python barrabrasil.py else echo "Error. Profile $1 does not exist." -- libgit2 0.21.2