Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

148
Vistas
Enable UWSGI caching only when Cache-Control headers are set

I'd like to use Nginx to cache a Uwsgi app. The app sets the Cache-Control header for some requests. The Nginx-cache should only be enabled for those requests and respect the max-age condition.

So I'm trying to set uwsgi_no_cache 1 for requests where upstream doesn't set Cache-Control. And uwsgi_no_cache 0 for requests where upstream does set the Cache-Control header.

However, this does not work:

set $no_cache 1;
if ($sent_http_cache_control) {
    set $no_cache 0;
}
uwsgi_no_cache $no_cache;

The problem lies with $sent_http_cache_control, unfortunately it does not reflect the header set upstream.

Is there a way of only enabling caching in Nginx when Cache-Control is set upstream?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

For headers returned by the upstream service you will need to use the $upstream_http_ prefix

https://nginx.org/en/docs/http/ngx_http_upstream_module.html#var_upstream_http_

So in your case it should be $upstream_http_cache_control

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda