From 0bd871eafd3c40888a75761986f81924fdd65f8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 17 May 2016 16:47:43 +0200 Subject: [PATCH] wcs: only cache templates for successful requests (#10966) --- template.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/template.py b/template.py index fc17f05..4542897 100644 --- a/template.py +++ b/template.py @@ -10,6 +10,7 @@ class RemoteTemplate(object): self.cache_filepath = os.path.join(self.cache_dirpath, self.cache_key) self.theme_skeleton_url = publisher.get_site_option('theme_skeleton_url') self.css_variant = publisher.get_site_option('css_variant', 'variables') + self.skip_cache = (request.response.status_code != 200) def get_template_content(self): import time, os, threading @@ -84,7 +85,8 @@ class RemoteTemplate(object): '[if-any first-user-link][first-user-link][end]', first_user_link) template_content = template_content.replace( '[if-any second-user-link][second-user-link][end]', second_user_link) - self.cache(template_content, page_id=r.headers.get('X-Combo-Page-Id')) + if not self.skip_cache: + self.cache(template_content, page_id=r.headers.get('X-Combo-Page-Id')) return template_content def cache(self, template_body, page_id=None): -- 2.8.1