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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:48:39+00:00 2026-05-29T03:48:39+00:00

I noticed that my per-site caching does not work because page response headers include:

  • 0

I noticed that my per-site caching does not work because page response headers include:

Vary:Cookie

Since I have google analytics installed it will update cookie on every page load which would make cache unusable.

I am not sure if I have added Vary:Cookie to page response headers implicitly or where it comes from. Any help appreciated.

Django 1.3.1

UPDATE:

it turns out that when session middleware is included and session is accessed, it will add Vary:Cookieheader to response. In my case reason is that 3rd party app is accessing session.

  • 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-29T03:48:39+00:00Added an answer on May 29, 2026 at 3:48 am

    The question is not really formulated as a question 🙂 but I thought I would point out a few things.

    Django cache is not sensitive to cookies by default. But you can tell him to be by setting the vary_on_* decorators.

    This means that the per-site cache you are talking about is something else – you mention google analytics, though it’s not really clear how related that is to caching itself.

    Thus you probably (?) have some caching fronted.

    If you were to be using nginx or varnish, you can customize the way vary affects the cache, and with nginx you can also remove it from the response so that the client does not receive it (including google analytics).

    If you simply want javascript not to see the session cookies, there’s a specific setting: SESSION_COOKIE_HTTPONLY.

    You should have a per-url-pattern strategy where you adapt cache behaviour to pages that depend, or not, to a logged-in user, by using or ignoring the Vary and Expire headers.

    [edit]

    using Nginx for caching

    If you are using nginx as a frontend and want to cache with it, there’s a very simple way to force caching for views where the cookies are unnecessary using :

    location /yourpath/ {
        proxy_cache cache_name;
        proxy_ignore_headers Set-Cookie;
        proxy_cache_valid 200 1d; # how long the nginx cache will last
        proxy_cache_key "$host$request_uri$cookie_user"; # you can still use /one/ cookie for your cache!
    
        ...
        proxy_pass @namedlocation;
    }
    

    you will need to define a cache, for more information checkout: https://serverfault.com/questions/30705/how-to-set-up-nginx-as-a-caching-reverse-proxy

    With uwsgi very similar settings apply, just they are prefixed uwsgi; checkout the uwsgi doc, but considering it is less verbose than the “proxy” doc I started from that as an example.

    If you want to completely “remove” cookies you can:

    location /path/ {
        proxy_hide_header Set-Cookie;
    }
    

    but I’m not sure this is what you want to do!

    On the other hand, if you want to better control browser’s cache too, you could re-set the vary header as you want:

    location /path/ {
        proxy_hide_header Vary;
    }
    

    and you can even reset it to something else:

        add_header    Vary User-Agent;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i noticed that paypal displays a very different favicon, one that's not just a
I noticed that Google maps is providing directions in my local language (hungarian) when
I noticed that you can call Queue.Synchronize to get a thread-safe queue object, but
I noticed that my Designer.vb file of one of my forms has a lot
We noticed that lots of bugs in our software developed in C# (or Java)
I noticed that there is one change about ASP.NET Routing. I cannot understand why
Just noticed that the style of the navigation menu on windows.com is just what
I noticed that the generic IEnumerator<T> inherits from IDisposable, but the non-generic interface IEnumerator
I noticed that doxygen uses the graphviz library for creating diagrams. Have you ever
I noticed that I can start a program with it's associated handler by writing

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.