【发布时间】:2016-07-02 01:39:20
【问题描述】:
页面是动态生成的,因为现在我需要PHPSESSID,所以无法缓存整个页面。但至少我想缓存所有静态内容,包括以两种方式包含在页面中的图像:
src="http://www.example.com/image.php?height=70&width=70&image=/ads/thumb/68370.jpg"
以及以常规方式
src="http://www.example.com/uploads/user/thumb/8705.jpg
在 Varnish 配置文件中,jpg, png 和 'image.php' 等 URL 被设置为缓存。
当页面在浏览器中打开两次时,Varnish 似乎工作正常,jpgs, pngs 和 image.php 年龄 > 0。
现在,当我运行一个脚本来预热清漆缓存,然后第一次在浏览器中打开任何页面时,所有jpgs, pngs 和image.php 的年龄总是 = 0
预热缓存的脚本:
wget --quiet -U Firefox http://$URL/$sitemap_file --no-cache --header='Cache- Control: no-cache' --output-document - | egrep -o "http(s?)://$URL[^ \"\'()\<>]+ " | while read line; do
if [[ $line == *.xml ]]
then
newURL=$line
wget --quiet -U Firefox $newURL --no-cache --header='Cache-Control: n o-cache' --output-document - | egrep -o "http(s?)://$URL[^ \"\'()\<>]+" | while read newline; do
time curl -A 'Cache Warmer' -sL -w "%{http_code} %{url_effective}\ n" $newline -o /dev/null 2>&1
echo $newline
done
else
time curl -A 'Cache Warmer' -sL -w "%{http_code} %{url_effective}\n" $line -o /dev/null 2>&1
echo $line
fi
done
css 或 js 等其他静态文件没有问题,因为它们对所有页面都是通用的,任何页面都可以将它们加载到缓存中,但每个页面的图像不同。
那么,是否可以缓存预热脚本中的图像?
感谢您的任何提示 德里克
【问题讨论】: