# Issue with uwsgi\_cache

**URL:** <https://www.ruby-forum.com/t/issue-with-uwsgi-cache/205866>\
**Category:** NGINX\
**Created:** [April 17, 2011, 9:06pm UTC](https://www.ruby-forum.com/t/issue-with-uwsgi-cache/205866 "2011-04-17T21:06:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [April 17, 2011, 9:06pm UTC](https://www.ruby-forum.com/t/issue-with-uwsgi-cache/205866/1 "2011-04-17T21:06:39Z")

</div>

I’m trying to make it so that I can cache certain pages generated by my  
uwsgi application. I’ve had some luck with the following stanzas:

[in http]  
uwsgi\_cache\_path /data/nginx/cache levels=1:2  
keys\_zone=one:1m  
inactive=7d max\_size=200m;

[in server]  
location / {  
uwsgi\_cache one;  
proxy\_cache\_use\_stale error timeout invalid\_header;  
uwsgi\_cache\_valid 200 1h;  
uwsgi\_cache\_key djcore$request\_uri;  
uwsgi\_pass ebdjango\_uwsgi;  
}

That works, but only when I go to /. Any request to any other page is  
not cached (at least as far as I can tell, no files are created in  
/data/nginx/cache, and when I run strace I don’t see it attempt to open  
any files).

As well, if I specify the following:

[in server]  
location /help {  
uwsgi\_cache one;  
proxy\_cache\_use\_stale error timeout invalid\_header;  
uwsgi\_cache\_valid 200 1h;  
uwsgi\_cache\_key djcore/help;  
uwsgi\_pass ebdjango\_uwsgi;  
}

It still won’t cache for the /help page.

At this point it seems that there’s something about the way this caching  
works that either I can’t find/understand in the docs, or just plain  
isn’t specified in the docs (less likely).

Has anyone had any luck with this? Can anyone shed any light on why  
this might be happening? I’ve been fighting with this for a few days  
now, and I’ve had no luck whatsoever.

## Thanks!

Michael Barrett  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![Michael\_Barrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3ec8ea/32.png) [@Michael\_Barrett](https://www.ruby-forum.com/u/Michael_Barrett)\
**Post date:** [April 17, 2011, 9:41pm UTC](https://www.ruby-forum.com/t/issue-with-uwsgi-cache/205866/2 "2011-04-17T21:41:52Z")

</div>

My bad - I think I’ve found the cause, and it doesn’t appear to be a  
problem with nginx or uwsgi.. but the developers application, which  
seems to send back the following headers, which I’m guessing nginx  
obliges:

Pragma: no-cache  
Cache-control: no-cache, must-revalidate, no-cache="Set-Cookie",  
private

Sorry for the repeated questions - and yay for nginx being so easily  
strace’able!

Thanks!

On Apr 17, 2011, at 12:05 PM, Michael Barrett wrote:

> ```
> proxy_cache_use_stale error timeout invalid_header;
> 
> ```
> 
> [in server]  
> At this point it seems that there’s something about the way this caching works  
> that either I can’t find/understand in the docs, or just plain isn’t specified in  
> the docs (less likely).

–  
Michael Barrett  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Michael\_Barrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3ec8ea/32.png) [@Michael\_Barrett](https://www.ruby-forum.com/u/Michael_Barrett)\
**Post date:** [April 19, 2011, 12:07am UTC](https://www.ruby-forum.com/t/issue-with-uwsgi-cache/205866/3 "2011-04-19T00:07:13Z")

</div>

Just to follow up - it didn’t actually end up being this issue either.  
The bigger problem is that the UWSGI application was sending back  
Set-Cookie in the headers. It makes sense that this would cause caching  
software to bail, since the last thing you want is the cookies you’re  
setting for one user to be given to another.

In my case though these cookies weren’t important in this particular  
instance, so I added the following to the config which causes it to  
remove the Set-Cookie headers all together:

```
    uwsgi_hide_header Set-Cookie;
    uwsgi_ignore_headers Set-Cookie;

```

That made caching work great. Thanks again for everyone’s help!

On Apr 17, 2011, at 12:41 PM, Michael Barrett wrote:

> > ```
> > proxy_cache_use_stale error timeout invalid_header;
> > 
> > ```
> > 
> > [in server]  
> > At this point it seems that there’s something about the way this caching works  
> > that either I can’t find/understand in the docs, or just plain isn’t specified in  
> > the docs (less likely).
> 
> –  
> Michael Barrett  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

–  
Michael Barrett  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
