Commits

Andriy Kornatskyy  committed 4d6c0af

Applied content caching profile to add handler in guestbook demo.

  • Participants
  • Parent commits 6ee5f19

Comments (0)

Files changed (2)

File demos/guestbook/views.py

 
 class AddHandler(BaseHandler):
 
+    @handler_cache(CacheProfile('both', duration=timedelta(hours=1),
+            vary_environ=['HTTP_ACCEPT_ENCODING']))
+    @handler_transforms(gzip_transform(compress_level=9, min_length=250))
     def get(self, greeting=None):
         greeting = greeting or Greeting()
         return self.render_response('add.html', greeting=greeting)

File doc/tutorial.rst

 Notice we added ``vary_environ`` and used WSGI environment variable
 ``HTTP_ACCEPT_ENCODING`` to be included into cache key used by content cache.
 
+We can apply more permissive content caching to ``AddHandler``::
+
+    class AddHandler(BaseHandler):
+
+        @handler_cache(CacheProfile('both', duration=timedelta(hours=1),
+                vary_environ=['HTTP_ACCEPT_ENCODING']))
+        @handler_transforms(gzip_transform(compress_level=9, min_length=500))
+        def get(self, greeting=None):
+            ...
+
+
+
 Try run application by issuing the following command::
 
     $ env/bin/python app.py