如果我运行此命令
varnishtop -i txurl
Run Code Online (Sandbox Code Playgroud)
该请求是"缓存"但不是"缓存".我看到"年龄= 0"(年龄保持清漆),如何编辑?
这是我的.php页面的请求
GET -Used http://example.com
User-Agent: lwp-request/5.810
200 OK
Cache-Control: max-age=60, public, must-revalidate
Connection: close
Date: Sat, 18 Feb 2012 12:14:33 GMT
Via: 1.1 varnish
Age: 0
Server: Apache
Vary: Accept-Encoding
Content-Type: text/html
Expires: Sat, 18 Feb 2012 12:24:33 GMT
Client-Date: Sat, 18 Feb 2012 12:14:34 GMT
Client-Peer: 173.236.219.104:80
Client-Response-Num: 1
Client-Transfer-Encoding: chunked
X-Cache: MISS
X-Cacheable: YES
X-Varnish: 840966561
Run Code Online (Sandbox Code Playgroud)
.htaccess代码
# BEGIN Expire headers
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 5 seconds"
ExpiresByType image/x-icon …Run Code Online (Sandbox Code Playgroud) 我试图使用清漆缓存提供gzip压缩.但是当我使用下面提到的varnish(default.vcl)配置将内容编码设置为gzip时.浏览器无法下载我将内容编码设置为gzip的内容.
清漆配置文件:
backend default {
.host = "127.0.0.1";
.port = "9000";
}
backend socketIO {
.host = "127.0.0.1";
.port = "8083";
}
acl purge {
"127.0.0.1";
"192.168.15.0"/24;
}
sub vcl_fetch {
/* If the request is for pictures, javascript, css, etc */
if (req.url ~ "^/public/" || req.url ~ "\.js"){
unset req.http.cookie;
set beresp.http.Content-Encoding= "gzip";
set beresp.ttl = 86400s;
set beresp.http.Cache-Control = "public, max-age=3600";
/*set the expires time to response header*/
set beresp.http.expires=beresp.ttl;
/* marker for vcl_deliver to reset Age: …Run Code Online (Sandbox Code Playgroud) 我安装了Varnish Cache我的CentOS服务器.我正确地尝试配置,但是当我读到许多文件时,我告诉我将apache端口更改Listen 80为Listen 8080.但我在我的服务器上找不到任何Listen 80线,/etc/httpd/conf/httpd.conf但我找到了0.0.0.0:80线路.这是一回事吗?如果那些是相同的瘦身,当我改变我的网站不工作.
我知道我犯了很大的逻辑错误,但我无法理解.
谢谢
我在我的vcl中有重复的代码,我想创建自定义函数而不嵌入内联C代码.有可能的?
非常感谢您的阅读!最好的祝福
我在端口80上运行Varnish,在同一台机器上运行8088端口的Apache(我用它进行开发/测试).
Apache被定义为VCL中的后端,如下所示:
backend default {
.host = "127.0.0.1";
.port = "8088";
.first_byte_timeout = 600s;
.probe = {
.request = "GET /index.php HTTP/1.1"
"Host: example.com"
"Connection: close";
.interval = 5s;
.timeout = 1s;
.window = 10;
.threshold = 8;
}
}
Run Code Online (Sandbox Code Playgroud)
如您所见,我设置了探针.但是,当我做varnishadm backend.list时,我得到了
Backend name Refs Admin Probe
default(127.0.0.1,,8088) 1 probe Sick 0/10
Run Code Online (Sandbox Code Playgroud)
当我执行wget 127.0.0.1:8088时,我得到了
--2017-04-17 10:20:20-- http://127.0.0.1:8088/
Connecting to 127.0.0.1:8088... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://magento2.dev/?SID=obcv7ifsq5b4ro9jr3hmpb7oi4 [following]
--2017-04-17 10:20:20-- http://magento2.dev/?SID=obcv7ifsq5b4ro9jr3hmpb7oi4
Resolving magento2.dev... 127.0.53.53
Connecting to magento2.dev|127.0.53.53|:80... …Run Code Online (Sandbox Code Playgroud) 对于Varnish,我看到两个进程正在运行,一个是其他进程的子进程,
nobody 10499 23634 0 22:25 ? 00:00:00 varnishd -f /etc/varnish/default.vcl -s malloc,1G -T 127.0.0.1:2000 -a 0.0.0.0:80
root 23634 1 0 19:33 ? 00:00:00 varnishd -f /etc/varnish/default.vcl -s malloc,1G -T 127.0.0.1:2000 -a 0.0.0.0:80
Run Code Online (Sandbox Code Playgroud)
它实际上如何运作?