Commits

Anonymous committed 39aec5a

I noticed that my tw2 widget resources got reloaded on every request, and traced
it down to a typo in the header parameter. This fixes setting Cache-Control:
max-age via tw2 configuration.

https://bitbucket.org/toscawidgets/tw2.core/issue/4/patch-for-max-age-header-typo-to-enable

  • Participants
  • Parent commits 8522cba

Comments (0)

Files changed (2)

tests/test_resources.py

     def test_cache_header(self):
         mw.resources.register('tw2.core', 'test_templates/simple_genshi.html')
         cache = tst_mw.get('/resources/tw2.core/test_templates/simple_genshi.html').headers['Cache-Control']
-        assert(cache == 'max_age=3600')
+        assert(cache == 'max-age=3600')
 
     #--
     # Links register resources

tw2/core/resources.py

             resp = wo.Response(request=req, app_iter=stream, content_type=ct)
             if enc:
                 resp.content_type_params['charset'] = enc
-        resp.cache_control = {'max_age': int(self.config.res_max_age)}
+        resp.cache_control = {'max-age': int(self.config.res_max_age)}
         return resp(environ, start_response)
 
 # Could use wsgiref, but this is python 2.4 compatible