0

Pages are generated dynamically, and because for now I need PHPSESSID the entire page cannot be cached. But at least I'd like to cache all static content including images which are included in pages in two ways:

src="http://www.example.com/image.php?height=70&width=70&image=/ads/thumb/68370.jpg"

as well as in a regular way

src="http://www.example.com/uploads/user/thumb/8705.jpg

In Varnish config file images like jpg, png and 'image.php' url are set to be cached.

When page is open in browser twice, Varnish seems to work fine, jpgs, pngs and image.php age is > 0.

Now, when I run a script to warm up varnish cache, and then open any page in browser for the first time, all jpgs, pngs and image.php age is always = 0

Script to warm up cache:

 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

There is no problem with other static files like css or js as they are common for all pages and any page can load them to cache, but images are different for each page.

So, is it possible to cache images from warming script?

Thank you for any hints Derek

dewu
  • 23
  • 4

1 Answers1

0

Varnish by default will hash on the complete URL (including query params) when caching an object.

Maybe the URLs in your warm up script have different query params then the URL you later enter into the browser?

Ronald
  • 2,864
  • 3
  • 25
  • 36