YahooArchive / boomerang

End user oriented web performance testing and beaconing
http://lognormal.github.com/boomerang/doc/
Other
1.18k stars 448 forks source link

Setting user_ip from a cookie #34

Open chmac opened 12 years ago

chmac commented 12 years ago

I'm trying to build a totally static site so as to be able to serve all pages from cache. In order to do that, I'm thinking about getting boomerang's user_ip value from a cookie. I'd ideally set it in a header, but I can't find any way to read the header within Javascript. By doing so, I can have the varnish server set the user's ip in a Set-Cookie header, and keep the whole site in varnish.

So far I've got varnish setting the header. I've got a solid handle on how to get the value from document.cookie, although I'm still wrapping my head around ipv6 compatibility.

Any feedback before I charge ahead? Am I barking up the wrong tree?

Cheers - Callum.

bluesmoon commented 12 years ago

Hi Callum,

You can read cookies in JavaScript using document.cookie, or just reuse boomerang's BOOMR.utils.getCookie and BOOMR.utils.getSubCookies methods.

Keep in mind though, that varnish may not cache responses that have a Set-Cookie header. I don't know if this changes if varnish itself sets the header.