How do you confirm cookies are removed from static files?

Felix Hanley felix at seconddrawer.com.au
Thu Sep 30 02:17:59 CEST 2010


The client will request that cookies be set and there is not much you
can do about that, except unset them. But they will still be in the
request.

The line in vcl_recv will remove set-cookie headers from the request.
The line in vcl_fetch will remove cookie headers before being stored in
the cache.

Your code looks fine. To confirm it is being stored, you will need to
use varnishlog or something.

-felix

On Wed, Sep 29, 2010 at 12:06:25PM -0400, Chris Altman wrote:
> I am new to Varnish and have read the documentation. My goal is to remove all cookies from static files. I am using Varnish 2.1.3
> 
> My VCL is:
> 
> sub vcl_recv {
>   if (req.url ~ "\.(png|gif|jpg|swf|css|js)$") {
>     unset req.http.cookie;
>   }
> }
> 
> sub vcl_fetch {
>   if (req.url ~ "\.(png|gif|jpg|swf|css|js)$") {
>     unset beresp.http.set-cookie;
>   }
> }
> 
> Question:
> I am confused because it appears the static files are served from Varnish but still have a cookie in their Request Headers. How do I remove the Request Headers cookie? Am I still gaining the benefits of Varnish if the Request Headers cookies exist?
> 
> Thank you,
> Chris Altman
> http://my.perqworks.com
> http://prtclr.com
> 
> 
> Response Headersview source
> Server	Apache/2.2.14 (Ubuntu)
> X-Powered-By	PHP/5.3.2-1ubuntu4.5
> Expires	Thu, 29 Sep 2011 15:56:42 GMT
> Vary	Accept-Encoding
> Last-Modified	Thu, 24 Jun 2010 21:16:50 GMT
> Cache-Control	max-age=31536000, public
> Content-Encoding	gzip
> Content-Type	text/css; charset=utf-8
> Content-Length	3339
> Date	Wed, 29 Sep 2010 15:56:42 GMT
> X-Varnish	2062520895
> Age	0
> Via	1.1 varnish
> Connection	keep-alive
> 
> 
> Request Headersview source
> Host	my.perqapp.com
> User-Agent	Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10
> Accept	text/css,*/*;q=0.1
> Accept-Language	en-us,en;q=0.5
> Accept-Encoding	gzip,deflate
> Accept-Charset	ISO-8859-1,utf-8;q=0.7,*;q=0.7
> Keep-Alive	115
> Connection	keep-alive
> Referer	http://my.perqapp.com/login
> Cookie	perq=20; __utma=90567579.1481902958.1285699566.1285768162.1285775102.4; __utmz=90567579.1285699566.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); perqworks=c7jcfkdueap5ggtbds500al703; __utmb=90567579.4.10.1285775102; __utmc=90567579
> 

> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> http://lists.varnish-cache.org/mailman/listinfo/varnish-misc


-- 
  email: felix at seconddrawer.com.au
    web: http://seconddrawer.com.au/
    gpg: E6FC 5BC6 268D B874 E546 8F6F A2BB 220B D5F6 92E3

Please don't send me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html




More information about the varnish-misc mailing list