Mercurial > libervia-web
comparison libervia/server/pages.py @ 1267:b5f920845d34
pages: delete existing cache instead of just ignoring it when `no-cache` is used
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 19 May 2020 11:02:33 +0200 |
parents | 6b7f9c3558cc |
children | e628724530ec |
comparison
equal
deleted
inserted
replaced
1266:6b7f9c3558cc | 1267:b5f920845d34 |
---|---|
975 """ | 975 """ |
976 if request.postpath: | 976 if request.postpath: |
977 # we are not on the final page, no need to go further | 977 # we are not on the final page, no need to go further |
978 return | 978 return |
979 | 979 |
980 if request.getHeader('cache-control') == 'no-cache': | 980 no_cache = request.getHeader('cache-control') == 'no-cache' |
981 return | |
982 | 981 |
983 profile = self.getProfile(request) or C.SERVICE_PROFILE | 982 profile = self.getProfile(request) or C.SERVICE_PROFILE |
984 | 983 |
985 if cache_type == C.CACHE_PUBSUB: | 984 if cache_type == C.CACHE_PUBSUB: |
986 service, node = kwargs["service"], kwargs["node"] | 985 service, node = kwargs["service"], kwargs["node"] |
1016 self._do_cache = [self, profile, cache_type, service, node, | 1015 self._do_cache = [self, profile, cache_type, service, node, |
1017 self.vhost_root, request.uri, locale] | 1016 self.vhost_root, request.uri, locale] |
1018 # we don't return the Deferreds as it is not needed to wait for | 1017 # we don't return the Deferreds as it is not needed to wait for |
1019 # the subscription to continue with page rendering | 1018 # the subscription to continue with page rendering |
1020 return | 1019 return |
1020 else: | |
1021 if no_cache: | |
1022 del (self.cache[profile][cache_type][service][node] | |
1023 [self.vhost_root][request.uri][locale][self]) | |
1024 log.debug(f"cache removed for {self}") | |
1025 return | |
1021 | 1026 |
1022 else: | 1027 else: |
1023 raise exceptions.InternalError("Unknown cache_type") | 1028 raise exceptions.InternalError("Unknown cache_type") |
1024 log.debug("using cache for {page}".format(page=self)) | 1029 log.debug("using cache for {page}".format(page=self)) |
1025 cache.last_access = time.time() | 1030 cache.last_access = time.time() |