# Disable Cookies Caching?

**URL:** <https://www.ruby-forum.com/t/disable-cookies-caching/190576>\
**Category:** NGINX\
**Created:** [June 23, 2010, 7:56am UTC](https://www.ruby-forum.com/t/disable-cookies-caching/190576 "2010-06-23T07:56:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MuFei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f6c823/32.png) [@MuFei](https://www.ruby-forum.com/u/MuFei)\
**Post date:** [June 23, 2010, 7:56am UTC](https://www.ruby-forum.com/t/disable-cookies-caching/190576/1 "2010-06-23T07:56:49Z")

</div>

Hi,

I just set up Nginx as a proxy to Apache for my vBulletin based site.  
Everything went well till I enabled Nginx caching. Once Nginx caching  
is enabled I’m and all users are no longer unable to log-in to the  
forum due cookie cashing. When I disable caching we are all able to  
log-in as usual.

Is there anyway to completely disable caching for cookies/sessions and  
keep caching for anything else?

Here are my settings for Nginx caching:

log\_format cache '\*\*\*$time\_local ’  
'$upstream\_cache\_status ’  
'Cache-Control: $upstream\_http\_cache\_control ’  
'Expires: $upstream\_http\_expires ’  
'"$request" ($status) ’  
'"$http\_user\_agent" ';  
access\_log /var/log/nginx/cache.access.log cache;  
proxy\_cache\_path /var/www/cache levels=1:2 keys\_zone=my-cache:8m  
max\_size=1000m inactive=7d;  
proxy\_temp\_path /var/www/cache/tmp;  
proxy\_buffering on;  
proxy\_cache my-cache;  
proxy\_cache\_valid 200 302 304 10m;  
proxy\_cache\_valid 301 1h;  
proxy\_cache\_valid 404 1m;  
proxy\_cache\_valid any 1m;

Also although there are already some caching in the folder  
/var/www/cache, the cache.access.log is empty and has no records in  
it, any idea why is that?

Regards

---

<div class="post-metadata">

**Author:** ![MuFei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f6c823/32.png) [@MuFei](https://www.ruby-forum.com/u/MuFei)\
**Post date:** [June 23, 2010, 9:49pm UTC](https://www.ruby-forum.com/t/disable-cookies-caching/190576/2 "2010-06-23T21:49:27Z")

</div>

On Wed, Jun 23, 2010 at 12:55 AM, MuFei [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> max\_size=1000m inactive=7d;  
> /var/www/cache, the cache.access.log is empty and has no records in  
> it, any idea why is that?

It seems proxy\_cache\_key is set to default, meaning that the cookie is  
not included. So everyone will see the same cached responses for GET  
requests, whether they log in or not.

try something like:  
proxy\_cache\_key “$host$request\_uri$cookie\_sessioncookie”;  
where “user” is replaced with whatever your session cookie is.

This still may not be usable, though, as you have things configured to  
cache all pages for at least 1 minute. That means users will  
potentially make a post and then not see any change in the forum  
pages. If the forum pages need to be truly dynamic, caching for logged  
in users might not be an option.

–  
RPM

---

<div class="post-metadata">

**Author:** ![MuFei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f6c823/32.png) [@MuFei](https://www.ruby-forum.com/u/MuFei)\
**Post date:** [June 24, 2010, 3:56pm UTC](https://www.ruby-forum.com/t/disable-cookies-caching/190576/3 "2010-06-24T15:56:32Z")

</div>

Hi,

I’ve tested a while ago only to guest users.  
The way i did it (I’m not using anymore) was creating a plugin in global  
start with a similar code:

vbsetcookie(‘usercache’, $vbulletin-\>userinfo[‘userid’], permanent);

Now you should have a new cookie name bbusercache to play with  
proxy\_cache\_key like indicated before.

Note that forums are very dynamic and didn’t made any tests.

Posted at Nginx Forum:

> **[Re: Disable Cookies Caching?](https://forum.nginx.org/read.php?2,101466,101899#msg-101899)**
>
> Hi, I just set up Nginx as a proxy to Apache for my vBulletin based site. Everything went well till I enabled Nginx caching. Once Nginx caching is enabled I'm and all users are no longer unable to log-in to the forum due cookie cashing. When I...
