varnish

Best way to cache RESTful API results of GET calls

独自空忆成欢 提交于 2019-12-18 10:37:19
问题 I'm thinking about the best way to create a cache layer in front or as first layer for GET requests to my RESTful API (written in Ruby). Not every request can be cached, because even for some GET requests the API has to validate the requesting user / application. That means I need to configure which request is cacheable and how long each cached answer is valid. For a few cases I need a very short expiration time of e.g. 15s and below. And I should be able to let cache entries expire by the

Configure multiple sites with Varnish

与世无争的帅哥 提交于 2019-12-17 21:24:46
问题 We have a server which needs to serve multiple domains though varnish e.g. example1.com, example2.com and example3.com Our current .vcl file looks like this: sub vcl_recv { set req.http.Host = "example1.com"; lookup; } How do I set the correct req.http.Host for the correct incoming request? 回答1: You can support multiple frontend domains this way: backend example1 { .host = "backend.example1.com"; .port = "8080"; } backend example2 { .host = "backend.example2.com"; .port = "8080"; } sub vcl

varnish实现缓存加速

风格不统一 提交于 2019-12-15 00:17:45
varnish实现缓存加速 一、采用varnish为nginx实现缓存加速 1、实验环境: (1)一台varnish缓存服务器,一台nginx服务器 (2)关闭防火墙和selinux 2.配置varnish (1)修改varnish配置文件: 创建目录:mkdir -pv /data/varnish/cache 修改属主:chown varnish.varnish /data/varnish/cache (2)测试: 二、varnish实现动静分离 (1)varnish配置: (2)测试: (3)附件内容设置多个组,并做负载: 示例: import directors backend imgsrv1 { .host = "192.168.10.11"; .port = "80"; } backend imgsrv2 { .host = "192.168.10.12"; .port = "80"; } backend appsrv1 { .host = "192.168.10.21"; .port = "80"; } backend appsrv2 { .host = "192.168.10.22"; .port = "80"; } sub vcl_init { new imgsrvs = directors.random(); imgsrvs.add_backend(imgsrv1

varnish 4: serve graced object if beresp.status is an error?

故事扮演 提交于 2019-12-14 04:06:20
问题 is there a way to change what is delivered to the client between the backend response and the delivery? i'm trying to figure out a way to continue to serve graced objects if the backend returns a 4xx or 5xx response (which don't get cached). the backend probe hits a static page, which will keep the backend healthy as long as the webserver on it is running, but dynamic pages will return errors if they run into problems. currently, graced objects will continue to be served if the probe fails (e

Varnish/Apache Random 503 Errors

倖福魔咒の 提交于 2019-12-14 01:31:34
问题 I'm running cPanel on a Rackspace cloud server that's hosting about 30 websites. I'm using Varnish 3.0.3 + Apache 2.2.23. I'm getting random 503 errors. If I restart the httpd process, they go away. I checked the Apache error_log, and I don't see anything related to a 503 error. Here's my Varnish config: backend default { .host = "198.61.161.65"; .port = "8080"; .connect_timeout = 600s; .first_byte_timeout = 600s; .between_bytes_timeout = 600s; } Here's my Varnish startup parameters: -a :80

部署Varnish缓存搭理服务器

有些话、适合烂在心里 提交于 2019-12-13 09:25:19
博文大纲: 一、Varnish概述 1.Varnish简介 2.Varnish和squid的区别 3.Varnish的工作原理 4.Varnish架构 5.Varnish配置 6.VCL中内置预设变量 7.VCL的子程序 8.特定功能语句 9.return语句 10.Varnish请求处理的步骤 11.Varnish的优雅模式 二、安装Varnish 1.客户端访问测试缓存 2.服务端测试清除缓存 3.配置http服务器的访问获取客户端的IP地址 一、Varnish概述 1.Varnish简介 Varnish是一款高性能且开源的反向代理服务器和HTTP加速器,其采用全新的软件体系机构,和现在的硬件体系紧密配合。与传统的squid相比,Varnish具有高性能、速度快、管理更加方便等优点,目前很多大型的网站都开始尝试使用Varnish来代替squid,这便是Varnish迅速发展的最根本的原因。 Varnish的主要特征: (1)缓存代理位置:可以使用内存也可以使用磁盘; (2)日志存储:日志存储在内存中; (3)支持虚拟内存的使用; (4)有精确的时间管理机制,即缓存的时间属性控制; (5)状态引擎架构:在不同的引擎上完成对不同的缓存和代理数据进行处理; (6)缓存管理:以二叉堆管理缓存数据,做到数据的及时清理; 2.Varnish和squid的区别 相同点:

Why is Varnish redirecting as 301?

夙愿已清 提交于 2019-12-13 06:28:35
问题 I have been deploying a mediawiki docker container (appscontainer/mediawiki) based on Apache2 on a VPS, and I put a fresh install of Varnish on top of it, to be able to proxied different subdomains to the proper applications on the same server. My current default.vcl configuration file look like the following: backend default { .host = "127.0.0.1"; .port = "8080"; } backend wikimedia { .host = "localhost"; .port = "8080"; } sub vcl_recv { if(req.http.host == "wiki.virtual-assembly.org") { set

How to add redirect exceptions using Varnish?

亡梦爱人 提交于 2019-12-13 03:27:28
问题 I am trying to redirect a path e.g. www.something.com/apple/pie to www.something.com/tickets/pie-details but also have some exceptions e.g. www.something.com/apple/helloworld does not get redirected to www.something.com/tickets/helloworld-details This is what I have tried but doesn't work: if (req.url ~ "^/apple/.*" && req.url != "^/apple/helloworld") { set req.url = "^/tickets/.*-details"; error 701 req.url; } 回答1: https://info.varnish-software.com/blog/rewriting-urls-with-varnish

Browser is “Connecting” to site on each page change

空扰寡人 提交于 2019-12-13 03:06:34
问题 In Chrome dev tools, on Network tab, loading HTML page of normal website (e.g. StackOverflow) at first time looks like this: ... if I continue browsing this website, the "Connecting" time is not present anymore, and request to HTML file looks like this: But on a website that I'm working on, the "Connecting" time is present on each page load : In Chrome dev tools documentation "Connecting" status is explained as: "Time it took to establish a connection, including TCP handshakes/retries, DNS

Magento Onepagechekout login issue when using Varnish

人盡茶涼 提交于 2019-12-12 18:54:19
问题 I'm using: Magento v1.7.0.2, Varnish cache v3.0.3 and One Page Checkout (OPC) module from IWD (v2.0.9) I've added routes "onepagecheckout" and "onestepcheckout" to routes which should be excluded from the cache in Varnish. I can see that OPC page is not loaded from Varnish and works as it should, however, when the quick login form is used on OPC page, it doesn't work properly together with Varnish. Even when all cache items (including Varnish full page cache) have been disabled in Magento