Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vcl 4.0;
- backend default {
- .host = "127.0.0.1";
- .port = "8081";
- }
- sub vcl_recv {
- # We use a header to track req.restarts value.
- set req.http.X-RESTARTS = req.restarts;
- # req.restart stays always 0 and thus
- # the condition is never true.
- if (req.restarts == 0) {
- unset req.http.X-FORCE-MISS;
- }
- # This condition is newer true as obj.hits
- # in vcl_hit stays always 0.
- if (req.http.X-FORCE-MISS == "1") {
- set req.hash_always_miss = true;
- }
- }
- sub vcl_hit {
- # We use a header to track obj.hits value.
- set req.http.X-OBJ-HITS = obj.hits;
- # obj.hits stays always 0 and thus
- # the condition is never true.
- if (obj.hits > 2) {
- set req.http.X-FORCE-MISS = "1";
- return (restart);
- }
- }
- sub vcl_deliver {
- # Here obj.hits increases like expected.
- if (obj.hits > 0) {
- set resp.http.X-Cache = "HIT";
- set resp.http.X-Cache-HITS = obj.hits;
- } else {
- set resp.http.X-Cache = "MISS";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement