Fix ETag computation for UIPlugins
This commit is contained in:
parent
f8a4d73c30
commit
0fb1a41fef
1 changed files with 6 additions and 2 deletions
|
|
@ -162,7 +162,7 @@ def index():
|
||||||
files = collect_files()
|
files = collect_files()
|
||||||
return _compute_date(files)
|
return _compute_date(files)
|
||||||
|
|
||||||
def compute_etag(files=None, lastmodified=None):
|
def compute_etag(files=None, lastmodified=None, additional=None):
|
||||||
if callable(custom_etag):
|
if callable(custom_etag):
|
||||||
try:
|
try:
|
||||||
etag = custom_etag()
|
etag = custom_etag()
|
||||||
|
|
@ -178,6 +178,8 @@ def index():
|
||||||
if lastmodified and not isinstance(lastmodified, basestring):
|
if lastmodified and not isinstance(lastmodified, basestring):
|
||||||
from werkzeug.http import http_date
|
from werkzeug.http import http_date
|
||||||
lastmodified = http_date(lastmodified)
|
lastmodified = http_date(lastmodified)
|
||||||
|
if additional is None:
|
||||||
|
additional = []
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
hash = hashlib.sha1()
|
hash = hashlib.sha1()
|
||||||
|
|
@ -186,11 +188,13 @@ def index():
|
||||||
hash.update(",".join(sorted(files)))
|
hash.update(",".join(sorted(files)))
|
||||||
if lastmodified:
|
if lastmodified:
|
||||||
hash.update(lastmodified)
|
hash.update(lastmodified)
|
||||||
|
for add in additional:
|
||||||
|
hash.update(add)
|
||||||
return hash.hexdigest()
|
return hash.hexdigest()
|
||||||
|
|
||||||
decorated_view = view
|
decorated_view = view
|
||||||
decorated_view = util.flask.lastmodified(lambda _: compute_lastmodified())(decorated_view)
|
decorated_view = util.flask.lastmodified(lambda _: compute_lastmodified())(decorated_view)
|
||||||
decorated_view = util.flask.etagged(lambda _: compute_etag())(decorated_view)
|
decorated_view = util.flask.etagged(lambda _: compute_etag(additional=cache_key()))(decorated_view)
|
||||||
decorated_view = util.flask.cached(timeout=-1,
|
decorated_view = util.flask.cached(timeout=-1,
|
||||||
refreshif=validate_cache,
|
refreshif=validate_cache,
|
||||||
key=cache_key,
|
key=cache_key,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue