惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News | PayPal Newsroom
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News: Ask HN
Hacker News: Ask HN
H
Hacker News: Front Page
Apple Machine Learning Research
Apple Machine Learning Research
TaoSecurity Blog
TaoSecurity Blog
Help Net Security
Help Net Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
V
V2EX
Hugging Face - Blog
Hugging Face - Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
人人都是产品经理
人人都是产品经理
博客园 - 三生石上(FineUI控件)
Security Latest
Security Latest
Cloudbric
Cloudbric
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Know Your Adversary
Know Your Adversary
A
Arctic Wolf
L
LangChain Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
The GitHub Blog
The GitHub Blog
P
Proofpoint News Feed
W
WeLiveSecurity
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
M
MIT News - Artificial intelligence
Google DeepMind News
Google DeepMind News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
小众软件
小众软件
NISL@THU
NISL@THU
云风的 BLOG
云风的 BLOG
P
Privacy & Cybersecurity Law Blog
S
Security @ Cisco Blogs
博客园 - 【当耐特】
I
InfoQ
Vercel News
Vercel News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Proofpoint News Feed
O
OpenAI News
Google DeepMind News
Google DeepMind News
N
News and Events Feed by Topic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
K
Kaspersky official blog
T
Threat Research - Cisco Blogs
量子位
宝玉的分享
宝玉的分享

Varnish

Varnish Explained - V2EX varnish 4.1 和 5.0 现在( 2016 年 10 月 19 日)满满的都是坑别用 - V2EX Varnish Cache 5.0 - V2EX 启用缓存后,大家如何解决网站即时显示新添加或修改的内容? - V2EX 大家帮忙看下这段 Varnish 缓存规则是什么原因导致的语法错误 - V2EX Fastly 写的他们为什么用 Varnish 做 CDN 的理由 - V2EX Varnish Massive Storage Engine - V2EX Varnish/nginx 反向代理如何解决后端获取 server_addr 是 127.0.0.1 的问题 - V2EX Varnish 一般是放在 Nginx 前面还是后面的? - V2EX 求助:关于 varnish 配置的问题 - V2EX VML - V2EX Varnish Cache 4.0.0 - V2EX varnish可以走ssl吗 - V2EX 怎么处理Varnish 动态输出? - V2EX
varnish 如何根据 header 动态设置缓存时间 - V2EX
luger1990 · 2018-06-09 · via Varnish

可能标题问的有点模糊。先说说现在配置 varnish 对某一个 url 缓存的配置吧 是这样的:

if(bereq.url ~ "/api/module/url") {
	set beresp.ttl = 14400m; #如果请求的 url 为 /api/module/url 那么缓存一天时间
}

但是我感觉这么一个个 url 设置起来太麻烦了,我能不能在我后端代码( java)中通过设置 header 来动态的去配置,比如我通过 response header 设置

setHeader('varnishCache','true')
setHeader('varnishCacheTime','14400m')

那么我 varnish 的代码设置如下:

if(beresp.http.varnishCache == "true"){ #根据 header 中的信息判断是否缓存
	set beresp.ttl = beresp.http.varnishCacheTime;#根据 header 中的时间设置缓存时间
}

但是上面这么配置 reload varnish 配置的时候会报错。不知道能不能实现我想的配置

既然问了就多问几个问题吧,哈哈哈哈 问题二: 如果我设置一个 url 的缓存时间为 10s,那么 10 秒内都不会发请求到后端,直接 varnish 返回了。万一第 11 秒缓存到期了,恰恰此时我后端服务处问题了返回了 503 或者超时,我能不能还继续用缓存中的数据,避免返回 503 或者 timeout。

希望各位大神指教