我有一个位于 Varnish 后面的 Plone 网站。除了一件事外,一切正常。
这是一个动态网站,因此会不时有新内容。场景如下:
我有一个显示项目列表的页面。此页面已被缓存。所以我通过某种形式添加了另一个项目,并返回到同一页面,但没有显示新项目。这是因为显示的页面来自缓存并且仍在其 TTL 内。
如何确保在提交新项目时,从缓存中清除该页面,并显示来自后端服务器的带有新项目的新页面?
我的简单VCL如图所示:
backend default {
.host = "127.0.0.1";
.port = "8080";
}
sub vcl_recv {
if (req.request != "GET" && req.request != "HEAD") {
# We only deal with GET and HEAD by default
return (pass);
}
# remove unnecessary cookies
if (req.http.cookie ~ "wc.cookiecredentials|Path|Domain") {
# found wc.cookiecredentials in request, passing to backend server
return (lookup);
} else {
unset req.http.cookie;
}
}
sub vcl_fetch {
#unset beresp.http.Set-Cookie;
set beresp.ttl …Run Code Online (Sandbox Code Playgroud) 这是一个愚蠢的问题,对不起......我试过谷歌搜索但无济于事。
我以为它只是来访,example.com:6082但这似乎没有加载任何东西。
# # Telnet admin interface listen address and port
VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1
VARNISH_ADMIN_LISTEN_PORT=6082
Run Code Online (Sandbox Code Playgroud)
另外,作为一个附带问题(我仍在努力使其工作),清漆是否会缓存任何文件类型,即使它是 RSS 提要或 .php 文件或其他任何文件?
我绞尽脑汁试图找出 .vcl 文件中的语法有什么问题。我不断收到错误:
Symbol not found: 'req.method' (expected type BOOL):
('input' Line 13 Pos 9)
if (req.method == "PURGE") {
--------##########--------------
Running VCC-compiler failed, exit 1
Run Code Online (Sandbox Code Playgroud)
我按照本教程进行操作https://www.varnish-software.com/blog/step-step-speed-wordpress-varnish-software
谁能发现我做错了什么吗?
这是整个文件:
# This is a basic VCL configuration file for varnish. See the vcl(7)
# man page for details on VCL syntax and semantics.
#
# Default backend definition. Set this to point to your content
# server.
#
backend default {
.host = "127.0.0.1";
.port = "8080";
}
sub vcl_recv …Run Code Online (Sandbox Code Playgroud) 我知道在 Varnish 中,您可以根据文档使用 vcl_hash 中的 hash_data() 将数据添加到缓存哈希。
出于调试目的,我希望能够看到构成哈希的任何内容的全部内容。
例如,如果我们可以这样做,那将非常有用:
# This won't work:
set req.http.X-DEBUG = "HASH-DATA:" + hash_data();
Run Code Online (Sandbox Code Playgroud)
有谁知道这是否可能?
我有一个使用一些第三方脚本和图像的网站,它们是拥有功能齐全的网站的关键。但由于这些第三方资源的缓存、压缩和 CDN 性能较差,网站性能受到了影响。而且他们甚至一个多月都没有改变。
我想使用我的 Varnish 实例来缓存这些第三方资源(JS、CSS 和图像)至少几个小时,并通过我的 cloudflare 进行优化,从我自己的服务器提供服务。
用清漆可以做到这一点吗?
我正在从这个方便的模板中复制一些 VCL 规则并在最新的稳定版 Varnish4 上运行。但是 VCL 的这一部分:
vcl 4.0;
sub vcl_init {
# ...
# Normalize query arguments
set req.url = std.querysort(req.url);
}
^
Run Code Online (Sandbox Code Playgroud)
返回此错误:
-- Logs begin at Tue 2016-03-15 10:44:31 UTC, end at Tue 2016-03-15 13:02:10 UTC. --
Mar 15 13:02:10 ip-172-31-10-46 reload-vcl[18044]: Message from VCC-compiler:
Mar 15 13:02:10 ip-172-31-10-46 reload-vcl[18044]: Symbol not found: 'std.querysort' (expected type STRING_LIST):
Mar 15 13:02:10 ip-172-31-10-46 reload-vcl[18044]: ('/etc/varnish/test.vcl' Line 55 Pos 23)
Mar 15 13:02:10 ip-172-31-10-46 reload-vcl[18044]: set req.url = …Run Code Online (Sandbox Code Playgroud) 对不起,我是Varnish的新手.
我在我的/etc/varnish/mysite.vlc中尝试了很多东西,但无法使其正常工作.
我想将特定网址重定向到另一个网址.示例:如果有人访问http://mysite1/thepage1.xml它应该去http://mysite2/thepage2.xml
varnishd -V
varnishd (varnish-3.0.5 revision 1a89b1f)
Copyright (c) 2006 Verdens Gang AS
Copyright (c) 2006-2011 Varnish Software AS
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激.
我正在管理一个网站,该网站目前正在运行一个非常标准的 varnish/apache 设置。客户端需要添加一个新域,该域从路径/查询字符串透明地提供服务,以便创建其站点的轻量级版本。例如:
用户访问 mobile.example.com,它指向与 example.com 相同的服务器
Varnish 将 mobile.example.com 请求重写为 example.com/mobile?theme=mobile
用户收到 apache 从 example.com/mobile?theme=mobile 提供的页面,但停留在 mobile.example.com
我们需要点击一个路径并在此处添加查询字符串,以及维护用户输入的任何路径,即:mobile.example.com/test 应在 example.com/mobile/test?theme=mobile 提供内容
使用 Varnish 4 执行此操作的任何提示?是否可以?
我在切片服务器前面使用清漆来缓存 Mapbox 切片。为了删除旧的图块,我打算使用禁令来有效地删除大量缓存的图块。我的问题是清漆仍然使用缓存的对象(至少age响应中表明了这一点)并且不联系后端。
curl -X BAN -H 'X-Purge-Regex: 5/3/4.pbf' varnish我首先请求 http://varnish/5/3/4.pbf,然后使用或 或者添加禁令varnishadm,然后ban obj.http.url ~ 5/3/4.pbf再次请求 http://varnish/5/3/4.pbf。
一开始我的禁令列表是空的:
Present bans:
1610117471.434488 1 C
Run Code Online (Sandbox Code Playgroud)
禁令已成功添加curl -X BAN -H 'X-Purge-Regex: 5/3/4.pbf' varnish
<!DOCTYPE html>
<html>
<head>
<title>200 Ban added</title>
</head>
<body>
<h1>Error 200 Ban added</h1>
<p>Ban added</p>
<h3>Guru Meditation:</h3>
<p>XID: 8</p>
<hr>
<p>Varnish cache server</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
并显示在禁止列表中
Present bans:
1610117369.028870 0 - obj.http.url ~ 5/3/4.pbf
1610117307.220739 1 C
Run Code Online (Sandbox Code Playgroud)
再次请求http://varnish/5/3/4.pbf后,ban列表显示使用了该ban
Present bans:
1610117471.434488 1 - …Run Code Online (Sandbox Code Playgroud) 我用来devicedetect.vcl将标题发送X-UA-Device到我的应用程序,因此它知道要呈现哪个布局。varnish 将为该标头设置的可能值为mobile或desktop。
在退出时,该标头将转换为Vary: User-Agent.
现在,作为一个单独的、独立的项目,我需要在resp对象上设置另一个标头(该标头在发送到客户端之前发送到我们的 Golang 代理)。该标头将被调用,X-Analytics-Device并且可能具有bot、mobile、tablet或 的值desktop。
后端服务器不需要做任何事情X-Analytics-Device。只有我们的 Go 代理会解析并删除此标头,然后再将其发送到客户端。
问题是,我需要X-Analytics-Device根据子例程的结果设置标头call devicedetect;,该子例程位于vcl_recv. 我需要最终将其设置在respis in上vcl_deliver,并且我需要知道传递数据的最佳方式。
我能想到的唯一可行的方法(基于我对 Varnish 的有限理解)是我需要设置一些其他标头,并稍后访问它。
也许是这样的(我bot暂时忽略了):
if (req.http.X-UA-Device ~ "^mobile") {
set req.http.X-UA-Device = "mobile";
set req.http.X-Analytics-Device = "mobile";
} elseif (req.http.X-UA-Device ~ "^tablet") {
set req.http.X-UA-Device = "desktop"; …Run Code Online (Sandbox Code Playgroud) varnish-vcl ×10
varnish ×9
caching ×4
varnish-4 ×2
.htaccess ×1
apache ×1
http-caching ×1
mapbox-gl-js ×1
postgis ×1
wordpress ×1