Projet

Général

Profil

0001-wcs-only-cache-templates-for-successful-requests-109.patch

Frédéric Péters, 17 mai 2016 16:49

Télécharger (1,41 ko)

Voir les différences:

Subject: [PATCH] wcs: only cache templates for successful requests (#10966)

 template.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
template.py
10 10
        self.cache_filepath = os.path.join(self.cache_dirpath, self.cache_key)
11 11
        self.theme_skeleton_url = publisher.get_site_option('theme_skeleton_url')
12 12
        self.css_variant = publisher.get_site_option('css_variant', 'variables')
13
        self.skip_cache = (request.response.status_code != 200)
13 14

  
14 15
    def get_template_content(self):
15 16
        import time, os, threading
......
84 85
                '[if-any first-user-link][first-user-link][end]', first_user_link)
85 86
        template_content = template_content.replace(
86 87
                '[if-any second-user-link][second-user-link][end]', second_user_link)
87
        self.cache(template_content, page_id=r.headers.get('X-Combo-Page-Id'))
88
        if not self.skip_cache:
89
            self.cache(template_content, page_id=r.headers.get('X-Combo-Page-Id'))
88 90
        return template_content
89 91

  
90 92
    def cache(self, template_body, page_id=None):
91
-