varnish - Varnish script for warming cache
问题描述
I am using this script:
#!/bin/bash
wget --output-document=/dev/null --header='Cache-Control: no-cache' --tries=1 --quiet --base=http://example.com --input-file=/path/to/urls.txt
which is calling some urls I want to warm in Varnish from a txt file.
For this to work I added in
Varnish vcl
this code:
acl warmuper_ip {
"10.20.30.40";
}
sub vcl_recv {
# the script varnish-cache-warmup.sh must always refresh the cache
if (client.ip ~ warmuper_ip && req.http.Cache-Control ~ "no-cache") {
set req.hash_always_miss = true;
}
}
My question is, although this is working, every time I use this is it clearing cache and then add my urls? Because I am newbie and I don't want to clear Varnish every time I run this script. I just want to cache my links without affection previous cached links.
解决方案
$req.http.Cache-Control ~ "no-cache"
我认为您从后端检索的内容不会被缓存。内容只是被获取和交付,但不会存储在缓存中。
推荐阅读
- python - 熊猫分组和求和/存储
- c# - 手动设置组合框项时如何使用 mvvm 中的绑定在 wpf 中设置组合框默认值
- asp.net-web-api - WebAPI 文件上传 MultipartFormDataStreamProvider 清理访问被拒绝
- python - 时间序列数据的 CV 拆分
- html - 相同长度字符的像素差异
- authentication - 在 .net core 2.0 身份验证中将列“id”更改为“userid”
- react-native - 如何使 FlatList 自动滚动?
- javascript - 如何在 Laravel 控制器中使用 jQuery 自动完成(=实时搜索)
- regex - Notepad ++正则表达式匹配字符串
- php - php70u 和 php70w 软件包有什么区别?