Author: leidel
Date: Wed Jan 21 01:52:06 2009
New Revision: 32
Modified:
trunk/docs/overview.txt
trunk/robots/views.py
Log:
Added optional caching for robots.txt files
Signed-off-by: Jannis Leidel <[email protected]>
Modified: trunk/docs/overview.txt
==============================================================================
--- trunk/docs/overview.txt (original)
+++ trunk/docs/overview.txt Wed Jan 21 01:52:06 2009
@@ -103,6 +103,15 @@
sequence of characters and a dollar sign (``$``) to match the end of the
URL,
e.g., ``'/*.jpg$'`` can be used to match all jpeg files.
+Caching
+=======
+
+You can optionally cache the generation of the ``robots.txt``. Add or
change the ``ROBOTS_CACHE_TIMEOUT`` setting with a value in seconds in your
Django settings file::
+
+ ROBOTS_CACHE_TIMEOUT = 60*60*24
+
+This tells Django to cache the ``robots.txt`` for 24 hours (86400
seconds). The default value is ``None`` (no caching).
+
Support
=======
Modified: trunk/robots/views.py
==============================================================================
--- trunk/robots/views.py (original)
+++ trunk/robots/views.py Wed Jan 21 01:52:06 2009
@@ -3,6 +3,7 @@
from django.http import HttpResponse
from django.core.urlresolvers import reverse, NoReverseMatch
from django.conf import settings
+from django.views.decorators.cache import cache_page
from robots.models import Rule
@@ -34,3 +35,7 @@
'sitemap_url': sitemap_url,
})
return HttpResponse(t.render(c), status=status_code, mimetype=mimetype)
+
+ROBOTS_CACHE_TIMEOUT = getattr(settings, 'ROBOTS_CACHE_TIMEOUT', None)
+if ROBOTS_CACHE_TIMEOUT:
+ rules_list = cache_page(rules_list, ROBOTS_CACHE_TIMEOUT)
\ No newline at end of file
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---