Mercurial > libervia-web
comparison src/server/pages.py @ 1052:cdf0ebed9db7
pages (caches): use request.uri to check cache, to avoid using same cache with pages using different parameters (e.g. different MAM filter for pubsub)
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 25 Jan 2018 09:00:00 +0100 |
parents | 6b1e1f13a299 |
children | f2170536ba23 |
comparison
equal
deleted
inserted
replaced
1051:d3ac6fb10fd5 | 1052:cdf0ebed9db7 |
---|---|
587 """ | 587 """ |
588 if request.postpath: | 588 if request.postpath: |
589 # we are not on the final page, no need to go further | 589 # we are not on the final page, no need to go further |
590 return | 590 return |
591 | 591 |
592 if request.args: | |
593 # TODO: requests with args are not cached for now | |
594 return | |
595 | |
596 profile = self.getProfile(request) or C.SERVICE_PROFILE | 592 profile = self.getProfile(request) or C.SERVICE_PROFILE |
597 | 593 |
598 if cache_type == C.CACHE_PUBSUB: | 594 if cache_type == C.CACHE_PUBSUB: |
599 service, node = kwargs['service'], kwargs['node'] | 595 service, node = kwargs['service'], kwargs['node'] |
600 if not node: | 596 if not node: |
606 return | 602 return |
607 if profile != C.SERVICE_PROFILE: | 603 if profile != C.SERVICE_PROFILE: |
608 # only service profile is cache for now | 604 # only service profile is cache for now |
609 return | 605 return |
610 try: | 606 try: |
611 cache = self.cache[profile][cache_type][service][node][self] | 607 cache = self.cache[profile][cache_type][service][node][request.uri][self] |
612 except KeyError: | 608 except KeyError: |
613 # no cache yet, let's subscribe to the pubsub node | 609 # no cache yet, let's subscribe to the pubsub node |
614 d1 = self.host.bridgeCall('psSubscribe', service.full(), node, {}, profile) | 610 d1 = self.host.bridgeCall('psSubscribe', service.full(), node, {}, profile) |
615 d1.addCallback(self.checkCacheSubscribeCb, service, node) | 611 d1.addCallback(self.checkCacheSubscribeCb, service, node) |
616 d1.addErrback(self.checkCacheSubscribeEb, service, node) | 612 d1.addErrback(self.checkCacheSubscribeEb, service, node) |
617 d2 = self.host.bridgeCall('psNodeWatchAdd', service.full(), node, profile) | 613 d2 = self.host.bridgeCall('psNodeWatchAdd', service.full(), node, profile) |
618 d2.addErrback(self.psNodeWatchAddEb, service, node) | 614 d2.addErrback(self.psNodeWatchAddEb, service, node) |
619 self._do_cache = [self, profile, cache_type, service, node] | 615 self._do_cache = [self, profile, cache_type, service, node, request.uri] |
620 # we don't return the Deferreds as it is not needed to wait for | 616 # we don't return the Deferreds as it is not needed to wait for |
621 # the subscription to continue with page rendering | 617 # the subscription to continue with page rendering |
622 return | 618 return |
623 | 619 |
624 else: | 620 else: |