Commit 306f2ed72340b5ad19d5a02701b4057c433b6948
1 parent
e98295a7
Exists in
master
barrabrasil.py: recolocado o etag. Adicionado data de modifica??o pelo build. pr…
…ofile e build.sh: adicionando campo com data de modifica??o.
Showing
3 changed files
with
15 additions
and
9 deletions
Show diff stats
app/barrabrasil.py
| @@ -38,28 +38,32 @@ def barra(): | @@ -38,28 +38,32 @@ def barra(): | ||
| 38 | f = app.open_resource('profile') | 38 | f = app.open_resource('profile') |
| 39 | cfg = Config(f) | 39 | cfg = Config(f) |
| 40 | profile = cfg.profile | 40 | profile = cfg.profile |
| 41 | + data = cfg.date | ||
| 41 | with app.open_resource('templates/%s/barra-brasil.js' % profile) as f: | 42 | with app.open_resource('templates/%s/barra-brasil.js' % profile) as f: |
| 42 | conteudo = f.read().decode('utf-8') | 43 | conteudo = f.read().decode('utf-8') |
| 43 | - #etag = hashlib.sha1(conteudo.encode('utf-8')).hexdigest() | ||
| 44 | - #if request.if_none_match and \ | ||
| 45 | - # etag in request.if_none_match: | ||
| 46 | - # resposta = Response(status=304) | ||
| 47 | - #else: # nao esta em cache do navegador | ||
| 48 | - resposta = make_response(conteudo) | ||
| 49 | - # resposta.set_etag(etag) | 44 | + etag = hashlib.sha1(conteudo.encode('utf-8')).hexdigest() |
| 45 | + if request.if_none_match and \ | ||
| 46 | + etag in request.if_none_match: | ||
| 47 | + resposta = Response(status=304) | ||
| 48 | + else: # nao esta em cache do navegador | ||
| 49 | + resposta = make_response(conteudo) | ||
| 50 | + resposta.set_etag(etag) | ||
| 50 | resposta.headers['Content-type'] = 'application/x-javascript' | 51 | resposta.headers['Content-type'] = 'application/x-javascript' |
| 51 | resposta.headers['Cache-control'] = 'public, max-age: 86400' #24 horas | 52 | resposta.headers['Cache-control'] = 'public, max-age: 86400' #24 horas |
| 52 | - resposta.headers['Last-Modified'] = 'Mon, 30 Sep 2013 19:08:30 GMT' | 53 | + resposta.headers['Last-Modified'] = data |
| 53 | return resposta | 54 | return resposta |
| 54 | 55 | ||
| 55 | @app.route('/static/opensans-bold.woff') | 56 | @app.route('/static/opensans-bold.woff') |
| 56 | def fonte(): | 57 | def fonte(): |
| 58 | + f = app.open_resource('profile') | ||
| 59 | + cfg = Config(f) | ||
| 60 | + data = cfg.date | ||
| 57 | f = app.open_resource('static/opensans-bold.woff') | 61 | f = app.open_resource('static/opensans-bold.woff') |
| 58 | conteudo = f.read().decode('base64') | 62 | conteudo = f.read().decode('base64') |
| 59 | resposta = make_response(conteudo) | 63 | resposta = make_response(conteudo) |
| 60 | resposta.headers['Content-type'] = 'application/x-font-woff' | 64 | resposta.headers['Content-type'] = 'application/x-font-woff' |
| 61 | resposta.headers['Cache-control'] = 'public, max-age: 86400' #24 horas | 65 | resposta.headers['Cache-control'] = 'public, max-age: 86400' #24 horas |
| 62 | - resposta.headers['Last-Modified'] = 'Mon, 30 Sep 2013 19:08:30 GMT' | 66 | + resposta.headers['Last-Modified'] = data |
| 63 | return resposta | 67 | return resposta |
| 64 | 68 | ||
| 65 | if __name__ == '__main__': | 69 | if __name__ == '__main__': |
app/profile
build.sh
| @@ -14,6 +14,7 @@ then | @@ -14,6 +14,7 @@ then | ||
| 14 | cd ../../app | 14 | cd ../../app |
| 15 | touch profile | 15 | touch profile |
| 16 | echo 'profile :' $profile > profile | 16 | echo 'profile :' $profile > profile |
| 17 | + echo 'date : "' $(date -R) '"'>> profile | ||
| 17 | python barrabrasil.py | 18 | python barrabrasil.py |
| 18 | else | 19 | else |
| 19 | echo "Error. Profile $1 does not exist." | 20 | echo "Error. Profile $1 does not exist." |