changeset 1167:7d2e098ea3f4

pages (cache): separate cached pages using locales, to avoid having a page cache in a specific locale used for an other one.
author Goffi <goffi@goffi.org>
date Fri, 12 Apr 2019 13:58:02 +0200
parents 5baf7ece44a0
children ea0caa7b1bcc
files libervia/server/pages.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/server/pages.py	Wed Apr 10 21:06:35 2019 +0200
+++ b/libervia/server/pages.py	Fri Apr 12 13:58:02 2019 +0200
@@ -927,9 +927,14 @@
             if profile != C.SERVICE_PROFILE:
                 #  only service profile is cache for now
                 return
+            session_data = self.host.getSessionData(request, session_iface.ISATSession)
+            locale = session_data.locale
+            if locale == C.DEFAULT_LOCALE:
+                # no need to duplicate cache here
+                locale = None
             try:
                 cache = (self.cache[profile][cache_type][service][node]
-                         [self.vhost_root][request.uri][self])
+                         [self.vhost_root][request.uri][locale][self])
             except KeyError:
                 # no cache yet, let's subscribe to the pubsub node
                 d1 = self.host.bridgeCall(
@@ -940,7 +945,7 @@
                 d2 = self.host.bridgeCall("psNodeWatchAdd", service.full(), node, profile)
                 d2.addErrback(self.psNodeWatchAddEb, service, node)
                 self._do_cache = [self, profile, cache_type, service, node,
-                                  self.vhost_root, request.uri]
+                                  self.vhost_root, request.uri, locale]
                 #  we don't return the Deferreds as it is not needed to wait for
                 # the subscription to continue with page rendering
                 return