Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3979160
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:08:09+00:00 2026-05-20T05:08:09+00:00

i know the django has some cache method such as the The per-site cache,The

  • 0

i know the django has some cache method such as the The per-site cache,The per-view cache,Specifying per-view cache and Template fragment caching
but what’s differece between those cache ?
the per-site cache means the cache system cache the whole site ?
how can i understand the words ‘cache the whole site’?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:08:09+00:00Added an answer on May 20, 2026 at 5:08 am

    I think the docs do a great job of describing this but I will paste it here and give a little description as well.

    Cache the whole site means django will attempt to cache every view you’ve set up via middleware.

    Per site cache docs
    http://docs.djangoproject.com/en/dev/topics/cache/#the-per-site-cache

    Once the cache is set up, the simplest way to use caching is to cache your entire site.

    Basically, it’s a set of middleware so it caches all views. Middleware is applied to every request/response.


    Per view cache docs
    http://docs.djangoproject.com/en/dev/topics/cache/#the-per-view-cache

    A more granular way to use the caching
    framework is by caching the output of
    individual views. django.views.decorators.cache defines a cache_page decorator that will automatically cache the view’s response for you.

    This is a per view cache. You can decide to cache a certain view by applying the @cache_page decorator to a specific view (as opposed to ALL views above)


    Template fragment cache docs
    http://docs.djangoproject.com/en/dev/topics/cache/#template-fragment-caching

    The {% cache %} template tag caches
    the contents of the block for a given
    amount of time.

    This lets you cache chunks of your template (as opposed to an entire view above), so for example you could cache an expensive query in your template while other pieces of the site are still served dynamically.

    This would be useful if certain pieces can’t be cached.. for example the classic problem of displaying a logged in user at the top wouldn’t be possible with a per view cache, as the user would need to be updated and thus the cache invalidated.


    If you read further in the docs, you’ll reach the cache api as well:

    Cache api docs
    http://docs.djangoproject.com/en/dev/topics/cache/#the-low-level-cache-api

    This is basically how you get control over the cache in python code (as opposed to the template, above).

    # imagine you have a function that takes a day to complete.
    cache.set('very_expensive_homepage_logic', takes_a_day_to_calculate())
    
    # now if you call get() with your key, it will be returned and you won't have to wait a day to calculate.
    cache.get('very_expensive_homepage_logic')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know you can override delete and save methods in DJango models, but can
I've had the admin site working for my django app before but now I
My django application has some 500 records in various tables in the database( postgres
I need to create some fixtures for django test. Does anyone know of a
I know that there are hundreds of pages written on Django v Rails, but
I've made a Django site, but I've drank the Koolaid and I want to
I know a bunch of Django, HTML, and CSS, but I somehow never got
Does anyone know of a Django 1.0 + postgresql + apache + mod_python VMware
I know you can specify fieldsets in django for Admin helpers. However, I cannot
In Django, I know using filter with multiple arguments gets translated into SQL AND

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.