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 6941989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:57:26+00:00 2026-05-27T12:57:26+00:00

I’m setting up a Django site to use memcached, via Django’s site-wide caching MiddleWare.

  • 0

I’m setting up a Django site to use memcached, via Django’s site-wide caching MiddleWare.

I planned to store pages in memcached for a very long time (because they don’t change very often, and because my whole site should comfortably fit into a relatively small amount of memory), and amend my code to delete pages from memcached when the data on those pages does change (to avoid stale pages).

However, Django’s MiddleWare sets the Cache-Control and Expires HTTP headers on its responses to the same values that memcached uses for its expiry policy. That means that if I set a very long expiry for cached pages in memcached, end users’ browsers will use that expiry too, making them more likely to get stale data.

Can I stop Django’s MiddleWare from doing this?

  • 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-27T12:57:26+00:00Added an answer on May 27, 2026 at 12:57 pm

    You can add

    @cache_control(must_revalidate=True, max_age=3600)
    

    decorator to each of your views to make browsers validate their cache contents every time page is loaded. It is available by importing

    from django.views.decorators.cache import cache_control
    

    After that, if content on server is changed, then browser will redownload page from server.

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

Sidebar

Related Questions

Building a Django app on a VPS. I am not very experienced with setting
I'm new to Django and setting up my first site. I have a Share
I'm setting up a very small and simple django project which will include basically
I have a Django site using a 5-star rating system for voting (I use
I want to set my Django site to use UTF-8 for MySQL in a
I've just set our development Django site to use redis for a cache backend
Django's noob question: I use dango.contrib.auth for managing users of my site. But now,
I have a very simple django site but I have trouble getting the images
I am trying to use coleifer/django-relationships to create user relationship system in my site.
I am setting up DJango admin to make a model editable. On the same

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.