changeset 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
files libervia/server/pages.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/server/pages.py	Tue May 19 11:02:32 2020 +0200
+++ b/libervia/server/pages.py	Tue May 19 11:02:33 2020 +0200
@@ -977,8 +977,7 @@
             #  we are not on the final page, no need to go further
             return
 
-        if request.getHeader('cache-control') == 'no-cache':
-            return
+        no_cache = request.getHeader('cache-control') == 'no-cache'
 
         profile = self.getProfile(request) or C.SERVICE_PROFILE
 
@@ -1018,6 +1017,12 @@
                 #  we don't return the Deferreds as it is not needed to wait for
                 # the subscription to continue with page rendering
                 return
+            else:
+                if no_cache:
+                    del (self.cache[profile][cache_type][service][node]
+                         [self.vhost_root][request.uri][locale][self])
+                    log.debug(f"cache removed for {self}")
+                    return
 
         else:
             raise exceptions.InternalError("Unknown cache_type")