VCL
vcl常用配置
不缓存摸一个资源
在vcl_recv中
if (req.url ~ "private") {
return (pass);
}
动静分离
先定一个多个backend
backend defualt {
.host = "192.168.1.56";
.port = "80";
}
backend websrv {
.host = "192.168.1.58";
.port = "80";
}
在vcl_recv中
if (rep.url ~ "\.php$") {
set req.backend_hint = websrv;
} else {
set req.backend_hint = default;
}
配置虚拟主机
在vcl_recv中配置
if (rep.http.host ~ "www.bux.com") {
set req.backend_hint = websrv;
}
if (rep.http.host ~ "ftp.bux.com") {
set req.backend_hint = default;
}
此时缓存是否命中
在deliver中配置, deliver就是将Server(Cache 服务器, 就是varnish)的相应报文发送给客户端
// 如果命中
if (obj.hits > 0) {
set resp.http.Is-Hit = "Hit";
} else {
set resp.http.Is-Hit = "Miss";
}
将cookie绑定的私有缓存转为共有缓存
在vcl_backend_response中
if (beresp.http.cache-control !~ "s-maxage") { // s-maxage表示共有缓存, 此时报文应该没有Set-Cookie字段
if (bereq.url ~ "\.jpg$") { // 如果请求的是图片就将其定义公共缓存到缓存服务器上
beresp.ttl = 3500s;
unset beresp.http.Set-Cookie;
}
}
健康检测
backend websrv {
.host = "192.168.1.56";
.port = "80";
.probe = {
.url = "http://192.168.1.59/test.html";
}
}
配置拒绝请求
在vcl_recv中
if (req.http.host ~ "ftp.bux.com") {
return (synth(405));
}
生产中一定要配置purge(清理缓存), 但是只能是机房中的, 同时对于miss的应该返回error 405 "Not in cache", 因为miss就表示这该资源不在缓存中, 无法清理
acl purgers {
"127.0.0.1"/8;
"192.168.1.0/24";
}
sub vcl_recv {
if (req.request == "PURGE") { // 客户端请求清理缓存
// 一定要有这个if, 防止其他主机随意修改
if (!client.ip ~ purgers) { // 如果不在acl中的主机请求清理则拒绝
return (pass);
}
return(purge);
}
}
curl发送PURGE请求方法, curl -X PURGE url
搭建集群
import directors;
sub vcl_init {
new cluster1 = directors.round_robin();
cluster1.add_backend(websrv1);
cluster1.add_backend(websrv2);
}
sub vcl_recv {
set req.backend_hint = cluster1.backend();
}
VCL的更多相关文章
- DevExpress VCL v16.1.3发布
ExpressPDFViewer # BC3840:包含action标题和action提示的 Action classes 和 resource strings 重命名: class名称末尾中包含'A ...
- 转:看看 Delphi XE2 为 VCL 提供的 14 种样式
http://www.linuxso.com/linuxbiancheng/8889.html 其实只提供了 个 vsf 样式文件, 还有默认的 Windows 样式, 共 种. 在空白窗体上添加 L ...
- Delphi:与VCL同步(Synchronize()、用消息来同步)
看本文时,可以同时参考:Delphi中线程类 TThread实现多线程编程(事件.临界区.Synchronize.WaitFor……) 先说一下RTL和VCL RTL(Run-Time library ...
- varnish4.1 配置文件default.vcl
varnish4.1 配置文件default.vcl # This .x VCL file vcl 4.0; backend default { .host = "127.0.0.1&quo ...
- 【温故Delphi】之VCL消息机制小结
TObject消息分派 procedure Dispatch(var Message); virtual; #负责分派消息到特定VCL组件的事件处理函数 procedure DefaultHandle ...
- DevExpress VCL 13.1.4支持Delphi /C++Builder XE5
DevExpress VCL 13.1.4支持Delphi /C++Builder XE5 重大变化 ExpressLibrary dxHalfOfPi常数声明已经从cxGeometry单元移到了cx ...
- Devexpress VCL Build v2014 vol 15.2.3 发布
2016年第一个版本,继续修补. New Major Features in 15.2 What's New in VCL Products 15.2 Breaking Changes To lear ...
- Devexpress VCL Build v2015 vol 15.2 开始测试
增加了几个小玩意,与大版本变化根本无法匹配. 具体可以官网了解 https://www.devexpress.com/Subscriptions/New-2015.xml?product=vcl
- Delphi的VCL组件库
Visual Component Library的缩写(可视组件库)VCL是Visual Component Library的缩写,即可视组件库,它是Delphi,C++Builder等编程语言的基本 ...
- 在XE5中 VCL空窗体的3个线程
中午看到技术群里有人讨论, XE5一个空窗体程序就包含了3个线程, 赶忙打开XE5开了个空窗体一看, 果然如此 再打开D7和2010看了一下, 都是一个线程 这时看到有人说一个是输入法, 一个是GDI ...
随机推荐
- fiddler扩展模拟弱网络环境设置
今天在qq群中有人问到怎么模拟app弱网络环境,我查了下资料,记得之前做测试的时候是设置fiddler断点,app请求后止于fiddler断点,app一直拿不到响应结果就应该要给出网络请求失败的提示, ...
- 安卓--ListView
实验目的: 学习使用ListView 实验要求: 实现一个列表,其中显示班级学号姓名,提供添加功能,如需要删去某一项,长按该项,通过弹出菜单显示删除功能. package com.flyuz.app3 ...
- AISing Programming Contest 2019C(DFS,BFS)
#include<bits/stdc++.h>using namespace std;int n,m;long long a=0,b=0,ans=0;char s[407][407];in ...
- ECS简介
https://www.cnblogs.com/yangrouchuan/p/7436533.html Unity下的ECS框架 Entitas简介 最近随着守望先锋制作组在gdc上发布的一个关于 ...
- 洛谷P2709 BZOJ 3781 小B的询问 (莫队)
题目描述 小B有一个序列,包含N个1~K之间的整数.他一共有M个询问,每个询问给定一个区间[L..R],求Sigma(c(i)^2)的值,其中i的值从1到K,其中c(i)表示数字i在[L..R]中的重 ...
- std::copy使用方法
推荐2个c++函数库,类定义的资料库: http://en.cppreference.com/w/cpp/algorithm/copy http://www.cplusplus.com/referen ...
- 2、OpenCV Python 图像属性获取
__author__ = "WSX" import cv2 as cv import numpy as np image = cv.imread("1.JPG" ...
- flink学习笔记-各种Time
说明:本文为<Flink大数据项目实战>学习笔记,想通过视频系统学习Flink这个最火爆的大数据计算框架的同学,推荐学习课程: Flink大数据项目实战:http://t.cn/EJtKh ...
- CF431B Shower Line
Many students live in a dormitory. A dormitory is a whole new world of funny amusements and possibil ...
- HTTP Status 500 - org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
HTTP Status 500 - org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.e ...