- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我不确定为什么在设置适当的缓存头时VCL将TTL计算为0。我希望有更多经验的人可能会发现确实很明显的东西。
这是日志
varnish_1 | * << BeReq >> 18
varnish_1 | - Begin bereq 17 pass
varnish_1 | - Timestamp Start: 1522327212.212730 0.000000 0.000000
varnish_1 | - BereqMethod GET
varnish_1 | - BereqURL /routes/%2F
varnish_1 | - BereqProtocol HTTP/1.1
varnish_1 | - BereqHeader Host: localhost:8081
varnish_1 | - BereqHeader accept: application/ld+json
varnish_1 | - BereqHeader User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Mobile Safari/537.36
varnish_1 | - BereqHeader DNT: 1
varnish_1 | - BereqHeader Referer: http://localhost:8081/
varnish_1 | - BereqHeader Accept-Encoding: gzip, deflate, br
varnish_1 | - BereqHeader Accept-Language: en-GB,en;q=0.9,en-US;q=0.8,la;q=0.7
varnish_1 | - BereqHeader Cookie: _ga=GA1.1.917775181.1515688563; Phpstorm-53bb5460=b5be55f5-d679-4bb9-b2b2-108bdac978eb; PHPSESSID=3gc3fulg7kdv0k5hiaitmlaq7e
varnish_1 | - BereqHeader If-None-Match: "90cd705e5c80bbb83aa64439f9b18c62"
varnish_1 | - BereqHeader X-Forwarded-For: 172.18.0.1
varnish_1 | - BereqHeader X-Varnish: 18
varnish_1 | - VCL_call BACKEND_FETCH
varnish_1 | - VCL_return fetch
varnish_1 | - BackendOpen 23 boot.default 172.18.0.4 80 172.18.0.5 34084
varnish_1 | - BackendStart 172.18.0.4 80
varnish_1 | - Timestamp Bereq: 1522327212.212948 0.000218 0.000218
varnish_1 | - Timestamp Beresp: 1522327217.902208 5.689478 5.689260
varnish_1 | - BerespProtocol HTTP/1.1
varnish_1 | - BerespStatus 200
varnish_1 | - BerespReason OK
varnish_1 | - BerespHeader Server: nginx/1.13.9
varnish_1 | - BerespHeader Content-Type: application/ld+json; charset=utf-8
varnish_1 | - BerespHeader Transfer-Encoding: chunked
varnish_1 | - BerespHeader Connection: keep-alive
varnish_1 | - BerespHeader X-Powered-By: PHP/7.2.3
varnish_1 | - BerespHeader Vary: Accept
varnish_1 | - BerespHeader Vary: Content-Type
varnish_1 | - BerespHeader Vary: Authorization
varnish_1 | - BerespHeader X-Content-Type-Options: nosniff
varnish_1 | - BerespHeader X-Frame-Options: deny
varnish_1 | - BerespHeader Cache-Control: max-age=0, public, s-maxage=3600
varnish_1 | - BerespHeader Date: Thu, 29 Mar 2018 12:40:17 GMT
varnish_1 | - BerespHeader Link: <http://localhost:8081/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"
varnish_1 | - BerespHeader ETag: "fe8fa0778f4ee8045999017ccf82c34f"
varnish_1 | - BerespHeader Cache-Tags: /routes/%252F,/pages/3d07e6ba3a1d4ba1860a1846c0c1436b,/layouts/72ecbecdf0c140db8ac146dc69d70e33,/nav_bars/ef102fd0830442348273c924ff62249f,/component_groups/e0cbdc6f83f3444ba0392d20497c19e0,/component_groups/bd7c54c561a34442869369d9d655f08f,/
varnish_1 | - TTL RFC 3600 10 -1 1522327218 1522327218 1522327217 0 3600
varnish_1 | - VCL_call BACKEND_RESPONSE
varnish_1 | - BerespHeader url: /routes/%2F
varnish_1 | - TTL VCL -1 3600 0 1522327218
varnish_1 | - BerespHeader X-Cacheable: NO:Not Cacheable
varnish_1 | - BerespHeader X-Cache-TTL: 0.000
varnish_1 | - TTL VCL 120 3600 0 1522327218
varnish_1 | - VCL_return deliver
varnish_1 | - Storage malloc Transient
varnish_1 | - ObjProtocol HTTP/1.1
varnish_1 | - ObjStatus 200
varnish_1 | - ObjReason OK
varnish_1 | - ObjHeader Server: nginx/1.13.9
varnish_1 | - ObjHeader Content-Type: application/ld+json; charset=utf-8
varnish_1 | - ObjHeader X-Powered-By: PHP/7.2.3
varnish_1 | - ObjHeader Vary: Accept, Content-Type, Authorization
varnish_1 | - ObjHeader X-Content-Type-Options: nosniff
varnish_1 | - ObjHeader X-Frame-Options: deny
varnish_1 | - ObjHeader Cache-Control: max-age=0, public, s-maxage=3600
varnish_1 | - ObjHeader Date: Thu, 29 Mar 2018 12:40:17 GMT
varnish_1 | - ObjHeader Link: <http://localhost:8081/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"
varnish_1 | - ObjHeader ETag: "fe8fa0778f4ee8045999017ccf82c34f"
varnish_1 | - ObjHeader Cache-Tags: /routes/%252F,/pages/3d07e6ba3a1d4ba1860a1846c0c1436b,/layouts/72ecbecdf0c140db8ac146dc69d70e33,/nav_bars/ef102fd0830442348273c924ff62249f,/component_groups/e0cbdc6f83f3444ba0392d20497c19e0,/component_groups/bd7c54c561a34442869369d9d655f08f,/
varnish_1 | - ObjHeader url: /routes/%2F
varnish_1 | - ObjHeader X-Cacheable: NO:Not Cacheable
varnish_1 | - ObjHeader X-Cache-TTL: 0.000
varnish_1 | - Fetch_Body 2 chunked stream
varnish_1 | - BackendReuse 23 boot.default
varnish_1 | - Timestamp BerespBody: 1522327217.902374 5.689644 0.000166
varnish_1 | - Length 3195
varnish_1 | - BereqAcct 588 0 588 1972 3195 5167
varnish_1 | - End
varnish_1 |
varnish_1 | * << Request >> 17
varnish_1 | - Begin req 16 rxreq
varnish_1 | - Timestamp Start: 1522327212.212645 0.000000 0.000000
varnish_1 | - Timestamp Req: 1522327212.212645 0.000000 0.000000
varnish_1 | - ReqStart 172.18.0.1 50692
varnish_1 | - ReqMethod GET
varnish_1 | - ReqURL /routes/%2F
varnish_1 | - ReqProtocol HTTP/1.1
varnish_1 | - ReqHeader Host: localhost:8081
varnish_1 | - ReqHeader Connection: keep-alive
varnish_1 | - ReqHeader accept: application/ld+json
varnish_1 | - ReqHeader User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Mobile Safari/537.36
varnish_1 | - ReqHeader DNT: 1
varnish_1 | - ReqHeader Referer: http://localhost:8081/
varnish_1 | - ReqHeader Accept-Encoding: gzip, deflate, br
varnish_1 | - ReqHeader Accept-Language: en-GB,en;q=0.9,en-US;q=0.8,la;q=0.7
varnish_1 | - ReqHeader Cookie: _ga=GA1.1.917775181.1515688563; Phpstorm-53bb5460=b5be55f5-d679-4bb9-b2b2-108bdac978eb; PHPSESSID=3gc3fulg7kdv0k5hiaitmlaq7e
varnish_1 | - ReqHeader If-None-Match: "90cd705e5c80bbb83aa64439f9b18c62"
varnish_1 | - ReqHeader X-Forwarded-For: 172.18.0.1
varnish_1 | - VCL_call RECV
varnish_1 | - VCL_return pass
varnish_1 | - VCL_call HASH
varnish_1 | - VCL_return lookup
varnish_1 | - VCL_call PASS
varnish_1 | - VCL_return fetch
varnish_1 | - Link bereq 18 pass
varnish_1 | - Timestamp Fetch: 1522327217.902388 5.689743 5.689743
varnish_1 | - RespProtocol HTTP/1.1
varnish_1 | - RespStatus 200
varnish_1 | - RespReason OK
varnish_1 | - RespHeader Server: nginx/1.13.9
varnish_1 | - RespHeader Content-Type: application/ld+json; charset=utf-8
varnish_1 | - RespHeader X-Powered-By: PHP/7.2.3
varnish_1 | - RespHeader Vary: Accept, Content-Type, Authorization
varnish_1 | - RespHeader X-Content-Type-Options: nosniff
varnish_1 | - RespHeader X-Frame-Options: deny
varnish_1 | - RespHeader Cache-Control: max-age=0, public, s-maxage=3600
varnish_1 | - RespHeader Date: Thu, 29 Mar 2018 12:40:17 GMT
varnish_1 | - RespHeader Link: <http://localhost:8081/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"
varnish_1 | - RespHeader ETag: "fe8fa0778f4ee8045999017ccf82c34f"
varnish_1 | - RespHeader Cache-Tags: /routes/%252F,/pages/3d07e6ba3a1d4ba1860a1846c0c1436b,/layouts/72ecbecdf0c140db8ac146dc69d70e33,/nav_bars/ef102fd0830442348273c924ff62249f,/component_groups/e0cbdc6f83f3444ba0392d20497c19e0,/component_groups/bd7c54c561a34442869369d9d655f08f,/
varnish_1 | - RespHeader url: /routes/%2F
varnish_1 | - RespHeader X-Cacheable: NO:Not Cacheable
varnish_1 | - RespHeader X-Cache-TTL: 0.000
varnish_1 | - RespHeader X-Varnish: 17
varnish_1 | - RespHeader Age: 0
varnish_1 | - RespHeader Via: 1.1 varnish-v4
varnish_1 | - VCL_call DELIVER
varnish_1 | - RespUnset url: /routes/%2F
varnish_1 | - RespHeader X-Cache: MISS
varnish_1 | - VCL_return deliver
varnish_1 | - Timestamp Process: 1522327217.902479 5.689834 0.000091
varnish_1 | - RespHeader Accept-Ranges: bytes
varnish_1 | - RespHeader Content-Length: 3195
varnish_1 | - Debug "RES_MODE 2"
varnish_1 | - RespHeader Connection: keep-alive
varnish_1 | - Timestamp Resp: 1522327217.902553 5.689908 0.000074
varnish_1 | - ReqAcct 568 0 568 2086 3195 5281
varnish_1 | - End
varnish_1 |
varnish_1 | * << Session >> 16
varnish_1 | - Begin sess 0 HTTP/1
varnish_1 | - SessOpen 172.18.0.1 50692 :80 172.18.0.5 80 1522327212.212513 21
varnish_1 | - Link req 17 rxreq
varnish_1 | - SessClose RX_TIMEOUT 10.695
varnish_1 | - End
vcl 4.0;
import std;
backend default {
.host = "api";
.port = "80";
# Health check
#.probe = {
# .url = "/";
# .timeout = 5s;
# .interval = 10s;
# .window = 5;
# .threshold = 3;
#}
}
# Hosts allowed to send BAN requests
acl ban {
"localhost";
"php";
}
sub vcl_backend_response {
# Ban lurker friendly header
set beresp.http.url = bereq.url;
# Add a grace in case the backend is down
set beresp.grace = 1h;
if (bereq.http.Cookie ~ "(UserID|_session)") {
set beresp.http.X-Cacheable = "NO:Got Session";
set beresp.uncacheable = true;
} elsif (beresp.ttl <= 0s) {
# Varnish determined the object was not cacheable
set beresp.http.X-Cacheable = "NO:Not Cacheable";
set beresp.http.X-Cache-TTL = beresp.ttl;
} elsif (beresp.http.set-cookie) {
# You don't wish to cache content for logged in users
set beresp.http.X-Cacheable = "NO:Set-Cookie";
set beresp.uncacheable = true;
} elsif (beresp.http.Cache-Control ~ "private") {
# You are respecting the Cache-Control=private header from the backend
set beresp.http.X-Cacheable = "NO:Cache-Control=private";
set beresp.uncacheable = true;
} else {
# Varnish determined the object was cacheable
set beresp.http.X-Cacheable = "YES";
}
}
sub vcl_deliver {
# Don't send cache tags related headers to the client
unset resp.http.url;
# Uncomment the following line to NOT send the "Cache-Tags" header to the client (prevent using CloudFlare cache tags)
#unset resp.http.Cache-Tags;
if (obj.hits > 0) {
set resp.http.X-Cache = "HIT";
} else {
set resp.http.X-Cache = "MISS";
}
}
sub vcl_recv {
# Remove the "Forwarded" HTTP header if exists (security)
unset req.http.forwarded;
# To allow API Platform to ban by cache tags
if (req.method == "BAN") {
if (client.ip !~ ban) {
return(synth(405, "Not allowed"));
}
if (req.http.ApiPlatform-Ban-Regex) {
ban("obj.http.Cache-Tags ~ " + req.http.ApiPlatform-Ban-Regex);
return(synth(200, "Ban added"));
}
return(synth(400, "ApiPlatform-Ban-Regex HTTP header must be set."));
}
}
# From https://github.com/varnish/Varnish-Book/blob/master/vcl/grace.vcl
sub vcl_hit {
if (obj.ttl >= 0s) {
# Normal hit
return (deliver);
} elsif (std.healthy(req.backend_hint)) {
# The backend is healthy
# Fetch the object from the backend
return (fetch);
} else {
# No fresh object and the backend is not healthy
if (obj.ttl + obj.grace > 0s) {
# Deliver graced object
# Automatically triggers a background fetch
return (deliver);
} else {
# No valid object to deliver
# No healthy backend to handle request
# Return error
return (synth(503, "API is down"));
}
}
}
最佳答案
在IRC上聊天后(用户fgs非常有帮助),我可以更好地阅读日志并了解为什么会发生这种情况。
vcl_recv返回的是传递而不是查找,因为cookie是在请求中发送的。
我错过了这里的文档:
https://varnish-cache.org/docs/4.1/users-guide/increasing-your-hitrate.html#cookies
关于caching - Varnish 缓存丢失-由VCL决定的TTL为0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49555139/
一些背景(是 TLabel and TGroupbox Captions Flicker on Resize 的延续): 所以,我有一个应用程序可以加载不同的插件并创建一个TPageControl 上
我正在从 this handy template 复制一些 VCL 规则并在最新稳定的 Varnish4 上运行。但是 VCL 的这一部分: vcl 4.0; sub vcl_init { #
无论如何,这就是我的分析。今天早上,我将我的应用程序“分发”给了我们的组织,结果发现,在 XE8 中对这个旧的 win32 应用程序进行了一个月的新工作后,不使用 Windows 7“Basic”主题
在执行命令时 sudo service varnish reload 我收到以下错误: nish@styx:~$ sudo service varnish reload * Reloading HT
所以我第一次使用 Varnish 。我花了很多时间阅读它是如何工作的,但我无法弄清楚如何有选择地清除缓存。 就像说我有一个这样的网址 /?account=123&url=google.com 另一个喜
首先,维基百科将控制面板小程序定义为: graphical user interface which allows users to view and manipulate basic system
我的主窗体(我的图像中的 form1)中央有一个页面控件,我想打开停靠在该页面控件中的其他表单。因为我的子窗体上有很多控件,所以我需要垂直和水平滚动条(在子窗体上我有事件滚动条选项处于事件状态),但这
在Varnish中,std.log子例程是否会对性能产生影响,我应该关注该影响?例如,如果我将它称为请求的3-4次,那么在处理大量请求时会产生累积效果吗? 据我所知,std.log通过请求锁定,写入消
VCL中有几个内置子例程; vcl_recv,vcl_pipe,vcl_pass,vcl_hit,vcl_miss等; 引用https://varnish-cache.org/docs/4.1/use
我有以下形式的 URL: http://some-site.com/api/v2/portal-name/some/webservice/call 我要获取的数据需要 http://portal-na
我现在遇到了一个相当罕见的情况。我有一个直接与 Windows 消息队列交互的应用程序。该应用程序还使用 LuaJIT 运行外部 Lua 脚本。我想要为这些脚本提供调试工具,因此我创建了一个普通的 V
使用 Delphi 7 IDE 进行调试时,如何单步执行程序文件/borland/delphi7/source 文件夹中的代码? 听起来是个愚蠢的问题,但好奇的人想要调试。 (并不是说我认为源有什么问
在我的编程团队中,我们都使用 Delphi XE2 Professional。我们刚刚发现,在不同的计算机上,可用的 VCL 样式数量不同。 VCL 样式从何而来?我是否需要小心地将样式从一个 Del
我注意到,当启用 VCL-Styles 时,即使没有按下 Alt 键,也会使用热键选择菜单中的项目。 这会干扰我的用户界面的其余部分,并且我发现样式库改变热键的行为非常奇怪。 我可以以某种方式消除这种
我有一个源自 TMemo 的控件。它工作得很好,直到我第一次使用 Delphi XE7 VCL Styles。在Delphi XE7下,样式不应用于控件的滚动条。如果使用深色主题/风格,看起来很糟糕,
我一直在尝试将我拥有的单位从 VCL 转换为 FMX。我使用的库之一是用于 TpenStyle 的 VCL.Graphics: wallstyle,pathstyle,solvedpathstyle:
我正在设置主菜单字体(通过 Screen.MenuFont)以匹配程序中其他地方使用的字体的名称/大小。但主菜单不会随表单的其余部分一起刷新 - 我必须将鼠标移到每个菜单项上才能让它以新字体重新绘制该
我正在设置主菜单字体(通过 Screen.MenuFont)以匹配程序中其他地方使用的字体的名称/大小。但主菜单不会随表单的其余部分一起刷新 - 我必须将鼠标移到每个菜单项上才能让它以新字体重新绘制该
我为其编写软件的产品之一是会计类应用程序。它用 C++ 编写,使用 C++ Builder 和 VCL 控件,连接到运行在 Linux 上的 PostgreSQL 数据库。 PostgreSQL 数据
我正在创建一个包含多个表单的 VCL 表单应用程序。我创建了一个名为 formCreateAppointment 的新表单。 我正在尝试通过 menuItem 中的这段代码加载表单: formCrea
我是一名优秀的程序员,十分优秀!