【发布时间】:2021-05-22 05:13:36
【问题描述】:
如果我的 cookie 具有一定的价值,我会尝试取消设置 cookie。
我尝试使用beresp.http.Set-Cookie 获取值,但这似乎在响应时在 Set-Cookie 中设置了第一个值。有什么办法可以提取第二个 Set-Cookie 的值吗?
编辑
这是我的响应标头
HTTP/1.1 200 OK
Server: nginx/1.14.0 (Ubuntu)
Date: Fri, 19 Feb 2021 09:47:53 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 12297
Connection: keep-alive
Cache-Control: no-cache, no-store
Pragma: no-cache
Content-Encoding: br
Set-Cookie: VarnishCustomerIsGuest=True; path=/
Set-Cookie: .Nop.Customer=62a224b9-3b5b-4e74-8200-cf341df111af; expires=Sat, 19 Feb 2022 09:47:53 GMT; path=/; httponly
Set-Cookie: .Nop.TempData=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; samesite=lax; httponly
Vary: Accept-Encoding
X-MiniProfiler-Ids: ["4f9a095d-bbd1-4ffe-81e1-31761363af25"]
X-TMP1000: VarnishCustomerIsGuest=True; path=/
X-Varnish: 163854
Age: 0
Via: 1.1 varnish (Varnish/5.2)
X-Cache: MISS
Accept-Ranges: bytes
我要做的是在 vcl_backend_response 获取客户 cookie。但是
beresp.http.Set-Cookie
给了我 VarnishCustomerIsGuest 的第一个 set-cookie 值,我不确定是否可以获得客户 cookie .Nop.Customer。
我的应用程序后端总是为每个请求设置 cookie,所以我要做的是根据 .Nop.Customer 值取消设置 cookie,这样对于某些特定客户,页面总是从清漆缓存中提供。
【问题讨论】:
-
请添加相关的 VCL 代码,您可以在其中从
beresp.http.Set-Cookie中提取值。这将帮助我了解您的问题,并帮助我找到解决方案。 -
感谢您的回复。我已经编辑了这个问题,并试图更具描述性。
标签: varnish varnish-vcl