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

  • Home
  • SEARCH
  • 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 3933056
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:33:30+00:00 2026-05-19T23:33:30+00:00

So: I always deploy my Django apps with memcached running alongside. For my purposes,

  • 0

So: I always deploy my Django apps with memcached running alongside. For my purposes, they’re always running on the same instance. I’m enabling the cache with these lines in settings.py:

CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
CACHE_MIDDLEWARE_SECONDS = 60
CACHE_MIDDLEWARE_KEY_PREFIX = "the_name_of_the_app"
SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"

… I can clearly see the performance benefits when memcache is running. But this is the most simplistic of caching strategies, according to the django docs on the subject — where should I go from here to get more performance? Does one have to manually festoon one’s models or querysets with memcache accessors, or is there a strategically better way?

I like memorized and have had some luck with it — but caching in django remains a black box to me. Please show me the way forward, if it’s a path you’re familiar with.

  • 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-19T23:33:30+00:00Added an answer on May 19, 2026 at 11:33 pm

    Memcache isn’t going to magically make your website faster. The absolute first thing you are going to need to do is figuring out what is expensive. A simple way to do this is to decorate your views or other functions to see how long they generally take to execute, for example:

    def print_latency(f):
        def wrapped(*args, **kwargs):
            try:
                start = time.time()
                r = f(*args, **kwargs)
            finally:
                print >>sys.stderr, 'Latency (%s): %.3fs' % (f.__name__, time.time() - start)
            return r
        wrapped.__name__ = f.__name__
        return wrapped
    
    @print_latency
    def my_view(request):
        ...
    

    The next thing to do is figure out what resources are cacheable, i.e., what data doesn’t change or doesn’t cause a horrible experience if it does? Then start at the top. Can you cache the templates? If not, can you cache the views? If not, can you cache the database calls? The latter is probably where you will end up unless you have a super-simple website.

    Then you’ll need to see if your calls to the db are very cacheable. You might need to break up complex queries into simpler ones.

    Caching isn’t magic and isn’t perfect. You may have worse latency with caching but better throughput. Or on average latency might be better but the worst latencies might be horrible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am I correct in assuming that I always need to explicitly deploy referenced assemblies
I always believe they did, but seeing some answers here make me doubt... Can
I always tend to forget these built-in Symfony functions for making links.
Always was interested why are Array.Sort() and Array.IndexOf() methods made static and similar ArrayList.Sort()
Always when I run java application it will display in Windows Task Manager is
I always seem to have a hard time starting a new Firefox extension. Can
I always use unix timestamps for everything, but am wondering if there is a
I always felt that expecting exceptions to be thrown on a regular basis and
I always seem to use Get when working with data (strongly typed or otherwise)
I always have found the open source space interesting but have never actually participated

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.