Welcome! Log In Create A New Profile

Advanced

Re: Issue with uwsgi_cache

Michael Barrett
April 18, 2011 06:08PM
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@gmail.com
>>
>>
>>
>>
>
> --
> Michael Barrett
> loki77@gmail.com
>
>
>
>

--
Michael Barrett
loki77@gmail.com





_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Issue with uwsgi_cache

Michael Barrett April 17, 2011 03:08PM

Re: Issue with uwsgi_cache

Michael Barrett April 17, 2011 03:42PM

Re: Issue with uwsgi_cache

Michael Barrett April 18, 2011 06:08PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 262
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready