Issue with uwsgi_cache
Michael Barrett
loki77 at gmail.com
Tue Apr 19 02:06:38 MSD 2011
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:
> 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:
>
>> 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
>> loki77 at gmail.com
>>
>>
>>
>>
>
> --
> Michael Barrett
> loki77 at gmail.com
>
>
>
>
--
Michael Barrett
loki77 at gmail.com
More information about the nginx
mailing list