Projet

Général

Profil

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

Frédéric Péters, 18 mai 2016 11:37

Télécharger (1,57 ko)

Voir les différences:

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

 template.py | 6 +++++-
 1 file changed, 5 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
17
        if self.skip_cache:
18
            return self.update_content()
16 19
        CACHE_REFRESH_TIMEOUT = 300
17 20
        try:
18 21
            cache_filepath_mtime = min((
......
84 87
                '[if-any first-user-link][first-user-link][end]', first_user_link)
85 88
        template_content = template_content.replace(
86 89
                '[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'))
90
        if not self.skip_cache:
91
            self.cache(template_content, page_id=r.headers.get('X-Combo-Page-Id'))
88 92
        return template_content
89 93

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