开发者

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 ...
    ]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜