配置的varnish,主要是做图片缓存,但是发现如果访问了一个不存在的路径图片,返回是404,就算把这个图片放上去了,重新访问
也是404,清除了这个图片的缓存访问才可以。请问怎么设置这种想404状态吗的不缓存backend default { .host = "ip"; .port = "81";}backend test { .host = "127.0.0.1";.port = "8080";}acl local { "localhost";"127.0.0.1"; }sub vcl_recv { if (req.http.host ~ "^js2.com$") { set req.backend = test; return (pass); }# if (beresp.status == "404")# { # return (pass);# } if (req.request == "PURGE") { if (!client.ip ~ local) { error 405 "Not Allowed."; return (lookup); } } if (req.request == "GET" && req.url ~ "\.(jpg|png|gif|swf|jpeg|ico)$") { unset req.http.cookie; } if (req.http.x-forwarded-for) { set req.http.X-Forwarded-For = req.http.X-Forwarded-For ", " client.ip; } else { set req.http.X-Forwarded-For = client.ip; } if (req.request != "GET" && req.request != "HEAD" && req.request != "PUT" && req.request != "POST" && req.request != "TRACE" && req.request != "OPTIONS" && req.request != "DELETE") { return (pipe); } if (req.request != "GET" && req.request != "HEAD") { return (pass); } if (req.http.Authorization || req.http.Cookie) { return (pass); } if (req.request == "GET" && req.url ~ "\.(php)($|\?)") { return (pass); } return (lookup); }sub vcl_pipe { return (pipe); }sub vcl_pass { return (pass); }sub vcl_hash { set req.hash += req.url; if (req.http.host) { set req.hash += req.http.host; } else { set req.hash += server.ip; } return (hash); } sub vcl_hit { if (!obj.cacheable) { return (pass); } return (deliver); } sub vcl_miss { return (fetch); }sub vcl_fetch { if (!beresp.cacheable) { return (pass); } if (beresp.http.Set-Cookie) { return (pass); } if (beresp.http.Pragma ~ "no-cache" || beresp.http.Cache-Control ~ "no-cache" || beresp.http.Cache-Control ~ "private") {return (pass); } if (req.request == "GET" && req.url ~ "\.(js|css|mp3|jpg|png|gif|swf|jpeg|ico)$") { set beresp.ttl = 7d; } return (deliver); } sub vcl_deliver { set resp.http.x-hits = obj.hits ; if (obj.hits > 0) { set resp.http.X-Cache = "HIT cqtel-bbs"; } else { set resp.http.X-Cache = "MISS cqtel-bbs"; } }