回复:RE: puzzle about unset req.http.cookie
yangxu4000 at sina.com
yangxu4000 at sina.com
Mon Jun 20 11:08:57 CEST 2011
thanks for replying,I want to cache images and js, But I saw someone says "If Images have cookie, it can not be cached,so you must unset cookie first",so I want to know is there any relations between images have cookie or not? thank you~
----- 原始邮件 -----
发件人:Mattias Geniar <mattias at nucleus.be>
收件人:<yangxu4000 at sina.com>,<varnish-dev at varnish-cache.org>
主题:RE: puzzle about unset req.http.cookie
日期:2011-6-20 16:58:06
> if(req.url ‾ ".(js|css|jpg|png|gif|swf|jpeg|ico)$){
> unset req.http.cookie;
> }
>
> it says if images have cookie,It can not be cached.
Actually, that's not what it says. You're saying if the requested file ends in .js, .css, .jpg, ... or any of those file types, you will unset any cookie that is being sent along and force it to be cached.
If you want to say "if the image has a cookie, don't cache it" you can do a check if a cookie exists on your request and just pass it on to your backend, something like this:
if (req.http.cookie) {
return (pass);
}
Regards,
Mattias Geniar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20110620/c70e44bd/attachment-0003.html>
More information about the varnish-dev
mailing list