【问题标题】:warming varnish cache including images?加热清漆缓存,包括图像?
【发布时间】: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, pngsimage.php 年龄 > 0。

现在,当我运行一个脚本来预热清漆缓存,然后第一次在浏览器中打开任何页面时,所有jpgs, pngsimage.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

cssjs 等其他静态文件没有问题,因为它们对所有页面都是通用的,任何页面都可以将它们加载到缓存中,但每个页面的图像不同。

那么,是否可以缓存预热脚本中的图像?

感谢您的任何提示 德里克

【问题讨论】:

    标签: caching varnish warm-up


    【解决方案1】:

    在缓存对象时,Varnish 默认会对完整的 URL(包括查询参数)进行哈希处理。

    也许您的预热脚本中的 URL 与您稍后输入浏览器的 URL 具有不同的查询参数?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-03
      • 2016-05-25
      • 1970-01-01
      • 1970-01-01
      • 2012-04-22
      • 2017-06-30
      • 2014-04-07
      • 2013-03-21
      相关资源
      最近更新 更多