<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html;charset=us-ascii'>
<style>BODY{font:10pt Tahoma, Verdana, sans-serif;}</style>
</head>
<body>
<br>How do i get varnish to cache all images?<br><br>I had varnish 1 working with this but it seems my vcl does not work at all with 2<br><br>Here is my VCL<br><br>#<br># This is a basic VCL configuration file for varnish. See the vcl(7)<br># man page for details on VCL syntax and semantics.<br>#<br># $Id: default.vcl 1818 2007-08-09 12:12:12Z des $<br>#<br><br># Default backend definition. Set this to point to your content<br># server.<br><br>backend default {<br> .host = "127.0.0.1";<br> .port = "80";<br>}<br><br><br>acl purge {<br> "localhost";<br>}<br><br>sub vcl_recv {<br><br> if (req.request == "PURGE") {<br> if (!client.ip ~ purge) {<br> error 405 "Not allowed.";<br> }<br> lookup;<br> }<br><br> if (req.request != "GET" && req.request != "HEAD") {<br> pipe;<br> }<br><br> if (req.http.Expect) {<br> pipe;<br> }<br><br> /* Always cache images and binaries */<br> if (req.url ~<br>"\.(jpg|jpeg|gif|png|tiff|tif|svg|swf|ico|vsd|doc|ppt|pps|xls|pdf|mp3|mp4|m4a|ogg|mov|avi|wmv|sxw|zip|gz|bz2|tgz|tar|rar|odc|odb|odf|odg|odi|odp|ods|odt|sxc|sxd|sxi|sxw|dmg|torrent|deb|msi|iso|rpm)$")<br>{<br> lookup;<br> }<br><br> /* Always cache CSS and javascript */<br> if (req.url ~ "\.(css|js)$") {<br> lookup;<br> }<br><br> lookup;<br>}<br><br>/* Deal with purge requests */<br>sub vcl_hit {<br> if (req.request == "PURGE") {<br> set obj.ttl = 0s;<br> error 200 "Purged";<br> }<br> deliver;<br>}<br><br>sub vcl_miss {<br> if (req.http.If-Modified-Since) {<br> pass;<br> }<br> if (req.request == "PURGE") {<br> error 404 "Not in cache";<br> }<br> fetch;<br>}<br><br>sub vcl_fetch {<br> if (!obj.valid) {<br> error;<br> }<br> if (!obj.cacheable) {<br> pass;<br> }<br> if (obj.http.Set-Cookie) {<br> pass;<br> }<br> if(obj.http.Set-Cookie){<br> pass;<br> }<br> if(obj.http.Pragma ~ "no-cache" ||<br> obj.http.Cache-Control ~ "no-cache" ||<br> obj.http.Cache-Control ~ "private"){<br> pass;<br> }<br> if (req.url ~ "(errorPage?)") {<br> set obj.ttl = 0s;<br> }<br> if (req.url ~ "(exceptionPage?)") {<br> set obj.ttl = 0s;<br> }<br> if (req.url ~ "(unauthorizedPage?)") {<br> set obj.ttl = 0s;<br> }<br> if (req.url ~ "(type=The+requested+Virtual+Kiosk+is+currently+not+available+from+%5Benter+Virtual+Kiosk+Sponsor+Name+here%5D.+Please+close+the+Virtual+Kiosk+and+try+again.)") {<br> set obj.ttl = 0s;<br> }<br><br> insert;<br>}<br><br>sub vcl_deliver {<br> remove resp.http.X-Varnish;<br> remove resp.http.Via;<br>}<br><br></body></html>