开发者

Is that possible to cache django flatpages?

开发者 https://www.devze.com 2023-02-14 23:32 出处:网络
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

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

精彩评论

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