# Possibble to use fastcgi cache with set-cookie header

**URL:** <https://www.ruby-forum.com/t/possibble-to-use-fastcgi-cache-with-set-cookie-header/193578>\
**Category:** NGINX\
**Created:** [August 20, 2010, 12:15am UTC](https://www.ruby-forum.com/t/possibble-to-use-fastcgi-cache-with-set-cookie-header/193578 "2010-08-20T00:15:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jools\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@Jools\_W](https://www.ruby-forum.com/u/Jools_W)\
**Post date:** [August 20, 2010, 12:15am UTC](https://www.ruby-forum.com/t/possibble-to-use-fastcgi-cache-with-set-cookie-header/193578/1 "2010-08-20T00:15:48Z")

</div>

Hi,

I’m wondering if it is possible to force fastcgi\_cache even when there  
is a Set-Cookie header? I was testing with

[http://nginxtest.exotica.org.uk/index.php](http://nginxtest.exotica.org.uk/index.php)

which sets

Set-Cookie: site=nginxtest; HttpOnly  
Expires: Thu, 19 Nov 1981 00:00:00 GMT  
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,  
pre-check=0  
Pragma: no-cache

but I can only cache it with nginx if i remove the Set-Cookie header.

my config.

http {  
fastcgi\_cache\_path /var/cache/nginx levels=1:2  
keys\_zone=fastcgicache:10M;  
}

server {  
listen 80;  
server\_name [nginxtest.exotica.org.uk](http://nginxtest.exotica.org.uk);

root /path/to/website  
index index.html index.php;

location ~ .php$ {  
fastcgi\_cache\_valid any 10m;  
fastcgi\_cache\_key $host$request\_uri;  
fastcgi\_ignore\_headers Cache-Control Expires;  
fastcgi\_cache fastcgicache;  
fastcgi\_pass unix:/somepath/fcgi.sock  
fastcgi\_index index.php;  
fastcgi\_param SCRIPT\_FILENAME $document\_root$fastcgi\_script\_name;  
include fastcgi\_params;  
}

}

---

<div class="post-metadata">

**Author:** ![Jools\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@Jools\_W](https://www.ruby-forum.com/u/Jools_W)\
**Post date:** [August 20, 2010, 12:24am UTC](https://www.ruby-forum.com/t/possibble-to-use-fastcgi-cache-with-set-cookie-header/193578/2 "2010-08-20T00:24:35Z")

</div>

> fastcgi\_ignore\_headers Cache-Control Expires;

Changing this to

fastcgi\_ignore\_headers Cache-Control Expires Set-Cookie;

seems to do the job, but this is not documented anywhere I could find  
(not on the wiki for example). Is this correct? if so, I’ll add it to  
the wiki (and if it is what version was this introduced?)

I’m running nginx 0.8.49 btw.

Best Regards

Jools

---

<div class="post-metadata">

**Author:** ![Jools\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@Jools\_W](https://www.ruby-forum.com/u/Jools_W)\
**Post date:** [August 20, 2010, 12:35am UTC](https://www.ruby-forum.com/t/possibble-to-use-fastcgi-cache-with-set-cookie-header/193578/3 "2010-08-20T00:35:07Z")

</div>

2010/8/20 Jools W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > fastcgi\_ignore\_headers Cache-Control Expires;
> 
> Changing this to
> 
> fastcgi\_ignore\_headers Cache-Control Expires Set-Cookie;
> 
> seems to do the job, but this is not documented anywhere I could find (not  
> on the wiki for example). Is this correct?

yes it is. But be careful using this on a site where cookies are used  
for authentication and cannot be switch between users.
