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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:21:51+00:00 2026-06-16T15:21:51+00:00

My django site have 2 languages and when the language change, nginx hits the

  • 0

My django site have 2 languages and when the language change, nginx hits the cache with old language and language doesn’t change (Of course, not cached pages changing). To prevent that I need to add “$sent_http_content_language” variable to my “proxy_cache_key” but not working, even if I tried with :

    add_header Test $sent_http_content_language;

http://wiki.nginx.org/HttpCoreModule#.24sent_http_HEADER

My Response Headers

  • 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-06-16T15:21:53+00:00Added an answer on June 16, 2026 at 3:21 pm

    I’m gonna take a stab… $sent_http_HEADER doesn’t make a whole lot of sense for a cache key, since that’s part of the response. nginx doesn’t have access to the response until it actually contacts the upstream server and performs the request.

    note that there’s no way for nginx to tell the upstream server “Hey… based on the response headers, you’ve just sent, i’ll serve the rest of the request from cache”.

    So… if you can’t tell from the request that the response is already in cache, you cannot use the cache at all.

    One way to resolve this is to use a cookie; you can add the users’ language preference to a cookie, which will be returned by the client on subsequent requests. Since that value is present on the request, you can use it in a cache key (like $cookie_lang, if the response had a Set-Cookie: lang=tr).


    There’s a related problem to this; even if you had this sort of caching at the server, using the response’s Language header, working; you would still not see an update in the client; because it would be in the browser cache. You cannot turn that cache off, and you cannot control it, except with the handful of cache-control headers. From the content you’ve posted, it looks like they are already set in a sensible way (5 minutes expired, Vary header lists cookie). That means that it’s up to you to honor that promise, and only change the response content in agreement with those request headers.

    Fortunately, adding a cookie to express the language does honor the cache-control headers you’re using.

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

Sidebar

Related Questions

I have and old django site (0.97-pre-SVN-7457) and I'm about to make some changes
I currently have a django site, and it's kind of slow, so I want
I have a Django site that takes in sensitive information. I use https/SSL, so
I have a django site using the basic django registration framework. I have my
I have enabled site-wide Django caching , but the third-party apps I am using
I have a similar question than django cross-site reverse . But i think I
I have a site running in django and want to make it available on
I have a django server that serves the basic site with user, auth etc
I have an application that uses Django 1.3 installed in python's site-packages. I want
I have an application in Django 1.2. Language is selectable (I18N and Locale =

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.