Is that possible to cache django flatpages?
Is that possible to cache django flatpages ? When I look at the code i开发者_运维问答t seems it is not done...
Yes, just cache your site as normal and make sure that FetchFromCacheMiddleware is before FlatpageFallbackMiddleware. In this case, caching doesn't need to be done on the application level.
Better way to do this is just cache flatpage views (not cache all views!)
I recommend something like this:
from django.contrib.flatpages import views
from django.views.decorators.cache import cache_page
urlpatterns = [
url(r'^pages/(?P<url>.*)$', cache_page(60 * 60)(views.flatpage), name='django.contrib.flatpages.views.flatpage'),
# other routes here ...
]
加载中,请稍侯......
精彩评论