From 1779cf1a64059815af0a1bf47fd49b82feb7a05d Mon Sep 17 00:00:00 2001 From: erbalito <45042116+erbalito@users.noreply.github.com> Date: Sun, 24 Feb 2019 21:37:03 -0300 Subject: [PATCH] resolves #1729 A fix to avoid an error when time_expire=0 and set the proper cache_control instead. --- gluon/cache.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/gluon/cache.py b/gluon/cache.py index 90939b60..e74e0532 100644 --- a/gluon/cache.py +++ b/gluon/cache.py @@ -600,15 +600,14 @@ class Cache(object): (session_, vars_, lang_, user_agent_, public_) = \ (session, vars, lang, user_agent, public) + expires = 'Fri, 01 Jan 1990 00:00:00 GMT' if time_expire: cache_control = 'max-age=%(time_expire)s, s-maxage=%(time_expire)s' % dict(time_expire=time_expire) - if not session_ and public_: - cache_control += ', public' - expires = (current.request.utcnow + datetime.timedelta(seconds=time_expire) - ).strftime('%a, %d %b %Y %H:%M:%S GMT') - else: - cache_control += ', private' - expires = 'Fri, 01 Jan 1990 00:00:00 GMT' + expires = (current.request.utcnow + datetime.timedelta(seconds=time_expire)).strftime( + '%a, %d %b %Y %H:%M:%S GMT') + else: + cache_control = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0' + cache_control += ', public' if not session_ and public_ else ', private' if cache_model: # figure out the correct cache key