{"action":"created","issue":{"url":"https://api.github.com/repos/nexcess/magento-turpentine/issues/1071","labels_url":"https://api.github.com/repos/nexcess/magento-turpentine/issues/1071/labels{/name}","comments_url":"https://api.github.com/repos/nexcess/magento-turpentine/issues/1071/comments","events_url":"https://api.github.com/repos/nexcess/magento-turpentine/issues/1071/events","html_url":"https://github.com/nexcess/magento-turpentine/issues/1071","id":126241137,"number":1071,"title":"Turpentine VCL generated config not working ( no headers, no caching, always PIPE )","user":{"login":"CrK01","id":16671690,"avatar_url":"https://avatars.githubusercontent.com/u/16671690?v=3","gravatar_id":"","url":"https://api.github.com/users/CrK01","html_url":"https://github.com/CrK01","followers_url":"https://api.github.com/users/CrK01/followers","following_url":"https://api.github.com/users/CrK01/following{/other_user}","gists_url":"https://api.github.com/users/CrK01/gists{/gist_id}","starred_url":"https://api.github.com/users/CrK01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CrK01/subscriptions","organizations_url":"https://api.github.com/users/CrK01/orgs","repos_url":"https://api.github.com/users/CrK01/repos","events_url":"https://api.github.com/users/CrK01/events{/privacy}","received_events_url":"https://api.github.com/users/CrK01/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-12T18:18:39Z","updated_at":"2016-01-12T18:23:18Z","closed_at":null,"body":"Hello all,\r\n\r\nwe are having a strange problem in a concrete magento ( I have more than 20 magento stores working with turpentine + varnish without problem ).\r\n\r\nThis install has haproxy -> varnish -> nginx + php-fpm ( I always do this config, and I think this is not relevant to the problem ).\r\n\r\nTurpentine applies OK config ( so it's talking OK to varnish ):\r\n\r\n        VCL successfully applied to: XXX.XXX.XXX.XXX:6082\r\n        The VCL file has been saved.\r\n        The configuration has been saved.\r\n\r\nThe problem is that web is not caching, I can't see any varnish/turpentine headers, it's acting like a proxy , and varnishlog or varnishstat don't show any HIT or MISS. \r\n\r\nTested with varnish 4.0 and 3.0 ( I normaly use 3.0 ).\r\n\r\nin the other hand, if I use a custom and simple vcl ( without applying turpentine config ), it's working , hitting and cahcing.\r\n\r\nMy custom WORKING vcl for 3.0:\r\n\r\n# This is a basic VCL configuration file for varnish.  See the vcl(7)\r\n# man page for details on VCL syntax and semantics.\r\n# \r\n# Default backend definition.  Set this to point to your content\r\n# server.\r\n# \r\n\r\ndirector eurofred round-robin {\r\n { .backend = { .host = \"172.16.220.131\"; .port = \"889\";} }\r\n}\r\n  \r\n# Only allow purging from specific IPs\r\nacl trusted {\r\n    \"localhost\";\r\n    \"127.0.0.1\";\r\n    \"172.16.220.131\";\r\n    \"172.16.220.127\";\r\n    \"172.16.220.128\";\r\n}  \r\n\r\n#\r\n# http://www.varnish-cache.org/docs/2.1/tutorial/vcl.html#vcl-recv\r\n# @param req Request object\r\nsub vcl_recv {\r\nset req.grace = 30s;\r\n if (req.http.x-forwarded-for) {\r\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\r\n }\r\n else {\r\n set req.http.X-Forwarded-For = client.ip;\r\n }\r\n\r\n if (req.request == \"PURGE\") {\r\n # Allow requests from trusted IPs to purge the cache\r\n if (!client.ip ~ trusted) {\r\n error 405 \"Not allowed.\";\r\n }\r\n ban(\"req.url ~ \" + req.url);\r\n error 200 \"Ok\"; #We don't go to backend\r\n #return(lookup); # @see vcl_hit\r\n }\r\n\r\n if (req.request != \"GET\" &&\r\n req.request != \"HEAD\" &&\r\n req.request != \"PUT\" &&\r\n req.request != \"POST\" &&\r\n req.request != \"TRACE\" &&\r\n req.request != \"OPTIONS\" &&\r\n req.request != \"DELETE\") {\r\n /* Non-RFC2616 or CONNECT which is weird. */\r\n return (pipe);\r\n }\r\n\r\n# Cache only GET or HEAD requests\r\n if (req.request != \"GET\" && req.request != \"HEAD\") {\r\n /* We only deal with GET and HEAD by default */\r\n return (pass);\r\n }\r\n\r\n# parse accept encoding rulesets to normalize\r\n if (req.http.Accept-Encoding) {\r\n if (req.http.Accept-Encoding ~ \"gzip\") {\r\n set req.http.Accept-Encoding = \"gzip\";\r\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\r\n set req.http.Accept-Encoding = \"deflate\";\r\n } else {\r\n # unkown algorithm\r\n remove req.http.Accept-Encoding;\r\n }\r\n }\r\n\r\n# Rules for static files\r\n if (req.url ~ \"\\.(jpeg|jpg|png|gif|ico|swf|js|css|gz|rar|txt|bzip|pdf)(\\?.*|)$\") {\r\n set req.http.staticmarker = \"1\";\r\n unset req.http.Cookie;\r\n\r\nreturn (lookup);\r\n }\r\n\r\n# Don't cache pages for Magento Admin\r\n # FIXME: change this rule if you use custom url in admin\r\n if (req.url ~ \"^/(index.php/)?admin\") {\r\n return(pass);\r\n }\r\n\r\n# Don't cache checkout/customer pages, product compare\r\n if (req.url ~ \"^/(index.php/)?(checkout|customer|onestepcheckout|onepagecheckout|catalog/product_compare|wishlist)\") {\r\n return(pass);\r\n }\r\n\r\n# Don't cache servired o paypal \r\nif (req.url ~ \"^/(index.php/)?(servired|paypal)\") {\r\n return(pass);\r\n }\r\n \r\n# Don't cache gomage_feed\r\nif (req.url ~ \"^/(gomage_feed/)\") {\r\n return(pass);\r\n }\r\n\r\n \r\n# Don't cache phpinfo\r\nif (req.url ~ \"^/(index.php/)?(p.php)\") {\r\n return(pass);\r\n }\r\n\r\n# Don't cache till session end\r\n if (req.http.cookie ~ \"nocache_stable\") {\r\n return(pass);\r\n }\r\n\r\n# Unique identifier witch tell Varnish use cache or not\r\n if (req.http.cookie ~ \"nocache\") {\r\n return(pass);\r\n }\r\n\r\n# Remove cookie\r\n unset req.http.Cookie;\r\n set req.http.magicmarker = \"1\"; #Instruct varnish to remove cache headers received from backend\r\n return(lookup);\r\n }\r\nsub vcl_pipe {\r\n# # Note that only the first request to the backend will have\r\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\r\n# # have it set for all requests, make sure to have:\r\n# # set req.http.connection = \"close\";\r\n# # here. It is not set by default as it might break some broken web\r\n# # applications, like IIS with NTLM authentication.\r\n return (pipe);\r\n}\r\n\r\n#sub vcl_pass {\r\n# return (pass);\r\n#}\r\n\r\n#sub vcl_hash {\r\n# set req.hash += req.url;\r\n# if (req.http.host) {\r\n# set req.hash += req.http.host;\r\n# } else {\r\n# set req.hash += server.ip;\r\n# }\r\n# return (hash);\r\n# }\r\n# Called after a cache lookup if the req. document was found in the cache.\r\nsub vcl_hit {\r\n if (req.request == \"PURGE\") {\r\n ban_url(req.url);\r\n error 200 \"Purged\";\r\n }\r\n\r\n #\r\n # ATTENTION!! I had to comment this to make it work on vernish 3.0!!!!\r\n # error message:\r\n # Symbol not found: 'obj.cacheable' (expected type BOOL):\r\n #\r\n # I'm not sure about it, please check!!!\r\n #\r\n #if (!obj.cacheable) {\r\n # return (pass);\r\n #}\r\n\r\n\r\n return (deliver);\r\n}\r\n\r\n# Called after a cache lookup and odc was not found in cache.\r\nsub vcl_miss {\r\n if (req.request == \"PURGE\"){\r\n error 200 \"Not in cache\";\r\n }\r\n return (fetch);\r\n}\r\n\r\n# Called after document was retreived from backend\r\n# @var req Request object.\r\n# @var beresp Backend response (contains HTTP headers from backend)\r\nsub vcl_fetch {\r\n set req.grace = 30s;\r\n\r\n# Current response should not be cached\r\n if(beresp.http.Set-Cookie ~ \"nocache=1\") {\r\n return (deliver);\r\n }\r\n\r\n# Flag set when we want to delete cache headers received from backend\r\n if (req.http.magicmarker){\r\n unset beresp.http.magicmarker;\r\n unset beresp.http.Cache-Control;\r\n unset beresp.http.Expires;\r\n unset beresp.http.Pragma;\r\n unset beresp.http.Cache;\r\n unset beresp.http.Server;\r\n unset beresp.http.Set-Cookie;\r\n unset beresp.http.Age;\r\n\r\n # default ttl for pages\r\n set beresp.ttl = 1d;\r\n }\r\n if (req.http.staticmarker) {\r\n set beresp.ttl = 30d; # static file cache expires in 30 days\r\n unset beresp.http.staticmarker;\r\n unset beresp.http.ETag; # Removes Etag in case we have multiple frontends\r\n }\r\n\r\nreturn (deliver);\r\n}\r\n\r\n# Called after a cached document is delivered to the client.\r\nsub vcl_deliver {\r\n if (obj.hits > 0) {\r\n set resp.http.X-Cache = \"HIT (\"+obj.hits+\")\";\r\n } else {\r\n set resp.http.X-Cache = \"MISS\";\r\n # set resp.http.X-Cache-Hash = obj.http.hash;\r\n }\r\n return (deliver);\r\n}\r\n\r\n---------------\r\n\r\nNow , the VCL that applies turpentine on this magento:\r\n\r\nC{\r\n#include <stdlib.h>\r\n#include <stdio.h>\r\n#include <time.h>\r\n#include <pthread.h>\r\nstatic pthread_mutex_t lrand_mutex = PTHREAD_MUTEX_INITIALIZER;\r\nvoid generate_uuid(char* buf) {\r\npthread_mutex_lock(&lrand_mutex);\r\nlong a = lrand48();\r\nlong b = lrand48();\r\nlong c = lrand48();\r\nlong d = lrand48();\r\npthread_mutex_unlock(&lrand_mutex);\r\nsprintf(buf, \"frontend=%08lx%04lx%04lx%04lx%04lx%08lx\",\r\na,\r\nb & 0xffff,\r\n(b & ((long)0x0fff0000) >> 16) | 0x4000,\r\n(c & 0x0fff) | 0x8000,\r\n(c & (long)0xffff0000) >> 16,\r\nd\r\n);\r\nreturn;\r\n}\r\n}C\r\nimport std;\r\nsub vcl_deliver {\r\nif (obj.hits > 0) {\r\nset resp.http.X-Cache = \"HIT\";\r\n} else {\r\nset resp.http.X-Cache = \"MISS\";\r\n}\r\n}\r\nbackend default {\r\n.host = \"172.16.220.131\";\r\n.port = \"889\";\r\n.first_byte_timeout = 300s;\r\n.between_bytes_timeout = 300s;\r\n}\r\nbackend admin {\r\n.host = \"172.16.220.131\";\r\n.port = \"889\";\r\n.first_byte_timeout = 21600s;\r\n.between_bytes_timeout = 21600s;\r\n}\r\nacl crawler_acl {\r\n\"127.0.0.1\";\r\n}\r\nacl debug_acl {\r\n}\r\n/* -- REMOVED\r\nsub generate_session {\r\nif (req.url ~ \".*[&?]SID=([^&]+).*\") {\r\nset req.http.X-Varnish-Faked-Session = regsub(\r\nreq.url, \".*[&?]SID=([^&]+).*\", \"frontend=\\1\");\r\n} else {\r\nC{\r\nchar uuid_buf [50];\r\ngenerate_uuid(uuid_buf);\r\nVRT_SetHdr(sp, HDR_REQ,\r\n\"\\030X-Varnish-Faked-Session:\",\r\nuuid_buf,\r\nvrt_magic_string_end\r\n);\r\n}C\r\n}\r\nif (req.http.Cookie) {\r\nstd.collect(req.http.Cookie);\r\nset req.http.Cookie = req.http.X-Varnish-Faked-Session +\r\n\"; \" + req.http.Cookie;\r\n} else {\r\nset req.http.Cookie = req.http.X-Varnish-Faked-Session;\r\n}\r\n}\r\nsub generate_session_expires {\r\nC{\r\ntime_t now = time(NULL);\r\nstruct tm now_tm = *gmtime(&now);\r\nnow_tm.tm_sec += 3600;\r\nmktime(&now_tm);\r\nchar date_buf [50];\r\nstrftime(date_buf, sizeof(date_buf)-1, \"%a, %d-%b-%Y %H:%M:%S %Z\", &now_tm);\r\nVRT_SetHdr(sp, HDR_RESP,\r\n\"\\031X-Varnish-Cookie-Expires:\",\r\ndate_buf,\r\nvrt_magic_string_end\r\n);\r\n}C\r\n}\r\n-- */\r\nsub vcl_recv {\r\nif (req.restarts == 0) {\r\nif (req.http.X-Forwarded-For) {\r\nset req.http.X-Forwarded-For =\r\nreq.http.X-Forwarded-For + \", \" + client.ip;\r\n} else {\r\nset req.http.X-Forwarded-For = client.ip;\r\n}\r\n}\r\nif(false) {\r\nset req.http.X-Varnish-Origin-Url = req.url;\r\n}\r\nif (req.http.Accept-Encoding) {\r\nif (req.http.Accept-Encoding ~ \"gzip\") {\r\nset req.http.Accept-Encoding = \"gzip\";\r\n} else if (req.http.Accept-Encoding ~ \"deflate\") {\r\nset req.http.Accept-Encoding = \"deflate\";\r\n} else {\r\nunset req.http.Accept-Encoding;\r\n}\r\n}\r\nif (req.http.User-Agent ~ \"iP(?:hone|ad|od)|BlackBerry|Palm|Googlebot-Mobile|Mobile|mobile|mobi|Windows Mobile|Safari Mobile|Android|Opera (?:Mini|Mobi)\") {\r\nset req.http.X-Normalized-User-Agent = \"mobile\";\r\n} else if (req.http.User-Agent ~ \"MSIE\") {\r\nset req.http.X-Normalized-User-Agent = \"msie\";\r\n} else if (req.http.User-Agent ~ \"Firefox\") {\r\nset req.http.X-Normalized-User-Agent = \"firefox\";\r\n} else if (req.http.User-Agent ~ \"Chrome\") {\r\nset req.http.X-Normalized-User-Agent = \"chrome\";\r\n} else if (req.http.User-Agent ~ \"Safari\") {\r\nset req.http.X-Normalized-User-Agent = \"safari\";\r\n} else if (req.http.User-Agent ~ \"Opera\") {\r\nset req.http.X-Normalized-User-Agent = \"opera\";\r\n} else {\r\nset req.http.X-Normalized-User-Agent = \"other\";\r\n}\r\nif (!false || req.http.Authorization ||\r\nreq.request !~ \"^(GET|HEAD|OPTIONS)$\" ||\r\nreq.http.Cookie ~ \"varnish_bypass=1\") {\r\nif (req.url ~ \"^(/media/|/skin/|/js/|/)(?:(?:index|litespeed)\\.php/)?admin\") {\r\nset req.backend = admin;\r\n}\r\nreturn (pipe);\r\n}\r\nset req.url = regsuball(req.url, \"([^:])//+\", \"\\1/\");\r\nif (req.url ~ \"^(/media/|/skin/|/js/|/)(?:(?:index|litespeed)\\.php/)?\") {\r\nset req.http.X-Turpentine-Secret-Handshake = \"1\";\r\nif (req.url ~ \"^(/media/|/skin/|/js/|/)(?:(?:index|litespeed)\\.php/)?admin\") {\r\nset req.backend = admin;\r\nreturn (pipe);\r\n}\r\nif (req.http.Cookie ~ \"\\bcurrency=\") {\r\nset req.http.X-Varnish-Currency = regsub(\r\nreq.http.Cookie, \".*\\bcurrency=([^;]*).*\", \"\\1\");\r\n}\r\nif (req.http.Cookie ~ \"\\bstore=\") {\r\nset req.http.X-Varnish-Store = regsub(\r\nreq.http.Cookie, \".*\\bstore=([^;]*).*\", \"\\1\");\r\n}\r\nif (req.url ~ \"/turpentine/esi/get(?:Block|FormKey)/\") {\r\nset req.http.X-Varnish-Esi-Method = regsub(\r\nreq.url, \".*/method/(\\w+)/.*\", \"\\1\");\r\nset req.http.X-Varnish-Esi-Access = regsub(\r\nreq.url, \".*/access/(\\w+)/.*\", \"\\1\");\r\nif (req.http.X-Varnish-Esi-Method == \"esi\" && req.esi_level == 0 &&\r\n!(false || client.ip ~ debug_acl)) {\r\nerror 403 \"External ESI requests are not allowed\";\r\n}\r\n}\r\nif (req.http.Cookie !~ \"frontend=\" && !req.http.X-Varnish-Esi-Method) {\r\nif (client.ip ~ crawler_acl ||\r\nreq.http.User-Agent ~ \"^(?:ApacheBench/.*|.*Googlebot.*|JoeDog/.*Siege.*|magespeedtest\\.com|Nexcessnet_Turpentine/.*)$\") {\r\nset req.http.Cookie = \"frontend=crawler-session\";\r\n} else {\r\nreturn (pipe);\r\n}\r\n}\r\nif (true &&\r\nreq.url ~ \".*\\.(?:css|js|jpe?g|png|gif|ico|swf)(?=\\?|&|$)\") {\r\nunset req.http.Cookie;\r\nunset req.http.X-Varnish-Faked-Session;\r\nreturn (lookup);\r\n}\r\nif (req.url ~ \"^(/media/|/skin/|/js/|/)(?:(?:index|litespeed)\\.php/)?(?:admin|api|cron\\.php)\" ||\r\nreq.url ~ \"\\?.*__from_store=\") {\r\nreturn (pipe);\r\n}\r\nif (true &&\r\nreq.url ~ \"(?:[?&](?:__SID|XDEBUG_PROFILE)(?=[&=]|$))\") {\r\nreturn (pass);\r\n}\r\nif (true && req.url ~ \"[?&](utm_source|utm_medium|utm_campaign|utm_content|utm_term|gclid|cx|ie|cof|siteurl)=\") {\r\nset req.url = regsuball(req.url, \"(?:(\\?)?|&)(?:utm_source|utm_medium|utm_campaign|utm_content|utm_term|gclid|cx|ie|cof|siteurl)=[^&]+\", \"\\1\");\r\nset req.url = regsuball(req.url, \"(?:(\\?)&|\\?$)\", \"\\1\");\r\n}\r\nif(false) {\r\nset req.http.X-Varnish-Cache-Url = req.url;\r\nset req.url = req.http.X-Varnish-Origin-Url;\r\nunset req.http.X-Varnish-Origin-Url;\r\n}\r\nreturn (lookup);\r\n}\r\n}\r\nsub vcl_pipe {\r\nunset bereq.http.X-Turpentine-Secret-Handshake;\r\nset bereq.http.Connection = \"close\";\r\n}\r\nsub vcl_hash {\r\nif(false && req.http.X-Varnish-Cache-Url) {\r\nhash_data(req.http.X-Varnish-Cache-Url);\r\n} else {\r\nhash_data(req.url);\r\n}\r\nif (req.http.Host) {\r\nhash_data(req.http.Host);\r\n} else {\r\nhash_data(server.ip);\r\n}\r\nhash_data(req.http.Ssl-Offloaded);\r\nif (req.http.X-Normalized-User-Agent) {\r\nhash_data(req.http.X-Normalized-User-Agent);\r\n}\r\nif (req.http.Accept-Encoding) {\r\nhash_data(req.http.Accept-Encoding);\r\n}\r\nif (req.http.X-Varnish-Store || req.http.X-Varnish-Currency) {\r\nhash_data(\"s=\" + req.http.X-Varnish-Store + \"&c=\" + req.http.X-Varnish-Currency);\r\n}\r\nif (req.http.X-Varnish-Esi-Access == \"private\" &&\r\nreq.http.Cookie ~ \"frontend=\") {\r\nhash_data(regsub(req.http.Cookie, \"^.*?frontend=([^;]*);*.*$\", \"\\1\"));\r\n}\r\nif (req.http.X-Varnish-Esi-Access == \"customer_group\" &&\r\nreq.http.Cookie ~ \"customer_group=\") {\r\nhash_data(regsub(req.http.Cookie, \"^.*?customer_group=([^;]*);*.*$\", \"\\1\"));\r\n}\r\nreturn (hash);\r\n}\r\nsub vcl_hit {\r\n}\r\nsub vcl_fetch {\r\nset req.grace = 15s;\r\nset beresp.http.X-Varnish-Host = req.http.host;\r\nset beresp.http.X-Varnish-URL = req.url;\r\nif (req.url ~ \"^(/media/|/skin/|/js/|/)(?:(?:index|litespeed)\\.php/)?\") {\r\nunset beresp.http.Vary;\r\nset beresp.do_gzip = true;\r\nif (beresp.status != 200 && beresp.status != 404) {\r\nset beresp.ttl = 15s;\r\nreturn (hit_for_pass);\r\n} else {\r\nif (beresp.http.Set-Cookie) {\r\nset beresp.http.X-Varnish-Set-Cookie = beresp.http.Set-Cookie;\r\nunset beresp.http.Set-Cookie;\r\n}\r\nunset beresp.http.Cache-Control;\r\nunset beresp.http.Expires;\r\nunset beresp.http.Pragma;\r\nunset beresp.http.Cache;\r\nunset beresp.http.Age;\r\nif (beresp.http.X-Turpentine-Esi == \"1\") {\r\nset beresp.do_esi = true;\r\n}\r\nif (beresp.http.X-Turpentine-Cache == \"0\") {\r\nset beresp.ttl = 15s;\r\nreturn (hit_for_pass);\r\n} else {\r\nif (true &&\r\nbereq.url ~ \".*\\.(?:css|js|jpe?g|png|gif|ico|swf)(?=\\?|&|$)\") {\r\nset beresp.ttl = 259200s;\r\nset beresp.http.Cache-Control = \"max-age=259200\";\r\n} elseif (req.http.X-Varnish-Esi-Method) {\r\nif (req.http.X-Varnish-Esi-Access == \"private\" &&\r\nreq.http.Cookie ~ \"frontend=\") {\r\nset beresp.http.X-Varnish-Session = regsub(req.http.Cookie,\r\n\"^.*?frontend=([^;]*);*.*$\", \"\\1\");\r\n}\r\nif (req.http.X-Varnish-Esi-Method == \"ajax\" &&\r\nreq.http.X-Varnish-Esi-Access == \"public\") {\r\nset beresp.http.Cache-Control = \"max-age=\" + regsub(\r\nreq.url, \".*/ttl/(\\d+)/.*\", \"\\1\");\r\n}\r\nset beresp.ttl = std.duration(\r\nregsub(\r\nreq.url, \".*/ttl/(\\d+)/.*\", \"\\1s\"),\r\n300s);\r\nif (beresp.ttl == 0s) {\r\nset beresp.ttl = 15s;\r\nreturn (hit_for_pass);\r\n}\r\n} else {\r\nset beresp.ttl = 2592000s;\r\n}\r\n}\r\n}\r\nreturn (deliver);\r\n}\r\n}\r\nsub vcl_deliver {\r\nif (req.http.X-Varnish-Faked-Session) {\r\nset resp.http.Set-Cookie = req.http.X-Varnish-Faked-Session +\r\n\"; expires=\" + resp.http.X-Varnish-Cookie-Expires + \"; path=/\";\r\nif (req.http.Host) {\r\nif (req.http.User-Agent ~ \"^(?:ApacheBench/.*|.*Googlebot.*|JoeDog/.*Siege.*|magespeedtest\\.com|Nexcessnet_Turpentine/.*)$\") {\r\nset resp.http.Set-Cookie = resp.http.Set-Cookie +\r\n\"; domain=\" + regsub(req.http.Host, \":\\d+$\", \"\");\r\n} else {\r\nif(req.http.Host ~ \"\") {\r\nset resp.http.Set-Cookie = resp.http.Set-Cookie +\r\n\"; domain=\";\r\n} else {\r\nset resp.http.Set-Cookie = resp.http.Set-Cookie +\r\n\"; domain=\" + regsub(req.http.Host, \":\\d+$\", \"\");\r\n}\r\n}\r\n}\r\nset resp.http.Set-Cookie = resp.http.Set-Cookie + \"; httponly\";\r\nunset resp.http.X-Varnish-Cookie-Expires;\r\n}\r\nif (req.http.X-Varnish-Esi-Method == \"ajax\" && req.http.X-Varnish-Esi-Access == \"private\") {\r\nset resp.http.Cache-Control = \"no-cache\";\r\n}\r\nif (false || client.ip ~ debug_acl) {\r\nset resp.http.X-Varnish-Hits = obj.hits;\r\nset resp.http.X-Varnish-Esi-Method = req.http.X-Varnish-Esi-Method;\r\nset resp.http.X-Varnish-Esi-Access = req.http.X-Varnish-Esi-Access;\r\nset resp.http.X-Varnish-Currency = req.http.X-Varnish-Currency;\r\nset resp.http.X-Varnish-Store = req.http.X-Varnish-Store;\r\n} else {\r\nunset resp.http.X-Varnish;\r\nunset resp.http.Via;\r\nunset resp.http.X-Powered-By;\r\nunset resp.http.Server;\r\nunset resp.http.X-Turpentine-Cache;\r\nunset resp.http.X-Turpentine-Esi;\r\nunset resp.http.X-Turpentine-Flush-Events;\r\nunset resp.http.X-Turpentine-Block;\r\nunset resp.http.X-Varnish-Session;\r\nunset resp.http.X-Varnish-Host;\r\nunset resp.http.X-Varnish-URL;\r\nunset resp.http.X-Varnish-Set-Cookie;\r\n}\r\n}\r\n-----------\r\n\r\nSome varnishlog:\r\n\r\n*   << BeReq    >> 131126    \r\n-   Begin          bereq 131125 pipe\r\n-   BereqMethod    GET\r\n-   BereqURL       /\r\n-   BereqProtocol  HTTP/1.1\r\n-   BereqHeader    Host: newtest.recambios.eurofred.es\r\n-   BereqHeader    User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:43.0) Gecko/20100101 Firefox/43.0\r\n-   BereqHeader    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n-   BereqHeader    Accept-Language: es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3\r\n-   BereqHeader    Accept-Encoding: gzip, deflate\r\n-   BereqHeader    Cookie: __utma=183355301.1729828039.1444184838.1444866271.1444930477.3; __utmz=183355301.1444184838.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _ga=GA1.2.1729828039.1444184838; __utma=23327662.1729828039.1444184838.1447635484.1451440183.20; __utmz\r\n-   BereqHeader    Authorization: Basic ZGVtbzpFdXJvZnJlZFByZTIwMTU=\r\n-   BereqHeader    Cache-Control: max-age=0\r\n-   BereqHeader    Connection: close\r\n-   BereqHeader    X-Forwarded-For: 10.99.0.42, 172.16.220.131, 172.16.220.131\r\n-   BereqHeader    X-Varnish: 131125\r\n-   BereqHeader    Connection: close\r\n-   VCL_call       PIPE\r\n-   BereqUnset     Connection: close\r\n-   BereqUnset     Connection: close\r\n-   BereqHeader    Connection: close\r\n-   VCL_return     pipe\r\n-   BackendOpen    14 default(172.16.220.131,,889) 172.16.220.131 47311 \r\n-   Backend        14 default default(172.16.220.131,,889)\r\n-   BackendClose   14 default(172.16.220.131,,889)\r\n-   BereqAcct      0 0 0 0 0 0\r\n-   End            \r\n\r\n*   << Request  >> 131125    \r\n-   Begin          req 131124 rxreq\r\n-   Timestamp      Start: 1452622474.673030 0.000000 0.000000\r\n-   Timestamp      Req: 1452622474.673030 0.000000 0.000000\r\n-   ReqStart       172.16.220.131 50583\r\n-   ReqMethod      GET\r\n-   ReqURL         /\r\n-   ReqProtocol    HTTP/1.1\r\n-   ReqHeader      Host: newtest.recambios.eurofred.es\r\n-   ReqHeader      User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:43.0) Gecko/20100101 Firefox/43.0\r\n-   ReqHeader      Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n-   ReqHeader      Accept-Language: es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3\r\n-   ReqHeader      Accept-Encoding: gzip, deflate\r\n-   ReqHeader      Cookie: __utma=183355301.1729828039.1444184838.1444866271.1444930477.3; __utmz=183355301.1444184838.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _ga=GA1.2.1729828039.1444184838; __utma=23327662.1729828039.1444184838.1447635484.1451440183.20; __utmz\r\n-   ReqHeader      Authorization: Basic ZGVtbzpFdXJvZnJlZFByZTIwMTU=\r\n-   ReqHeader      Cache-Control: max-age=0\r\n-   ReqHeader      X-Forwarded-For: 10.99.0.42\r\n-   ReqHeader      Connection: close\r\n-   ReqUnset       X-Forwarded-For: 10.99.0.42\r\n-   ReqHeader      X-Forwarded-For: 10.99.0.42, 172.16.220.131\r\n-   VCL_call       RECV\r\n-   ReqUnset       X-Forwarded-For: 10.99.0.42, 172.16.220.131\r\n-   ReqHeader      X-Forwarded-For: 10.99.0.42, 172.16.220.131, 172.16.220.131\r\n-   VCL_return     pipe\r\n-   VCL_call       HASH\r\n-   VCL_return     lookup\r\n-   Link           bereq 131126 pipe\r\n-   Timestamp      Pipe: 1452622474.673281 0.000251 0.000251\r\n-   Timestamp      PipeSess: 1452622475.245652 0.572622 0.572371\r\n-   PipeAcct       904 955 0 18193\r\n-   End            \r\n\r\n*   << Session  >> 131124    \r\n-   Begin          sess 0 HTTP/1\r\n-   SessOpen       172.16.220.131 50583 172.16.220.131:81 172.16.220.131 81 1452622474.672969 11\r\n-   Link           req 131125 rxreq\r\n-   SessClose      TX_PIPE 0.573\r\n-   End            \r\n\r\n*   << BeReq    >> 342       \r\n-   Begin          bereq 341 pipe\r\n-   BereqMethod    GET\r\n-   BereqURL       /js/solrsearch/autocomplete.css\r\n-   BereqProtocol  HTTP/1.1\r\n-   BereqHeader    Host: newtest.recambios.eurofred.es\r\n-   BereqHeader    User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:43.0) Gecko/20100101 Firefox/43.0\r\n-   BereqHeader    Accept: text/css,*/*;q=0.1\r\n-   BereqHeader    Accept-Language: es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3\r\n-   BereqHeader    Accept-Encoding: gzip, deflate\r\n-   BereqHeader    Referer: http://newtest.recambios.eurofred.es/\r\n-   BereqHeader    Cookie: __utma=183355301.1729828039.1444184838.1444866271.1444930477.3; __utmz=183355301.1444184838.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _ga=GA1.2.1729828039.1444184838; __utma=23327662.1729828039.1444184838.1447635484.1451440183.20; __utmz\r\n-   BereqHeader    Authorization: Basic ZGVtbzpFdXJvZnJlZFByZTIwMTU=\r\n-   BereqHeader    Cache-Control: max-age=0\r\n-   BereqHeader    Connection: close\r\n-   BereqHeader    X-Forwarded-For: 10.99.0.42, 172.16.220.131, 172.16.220.131\r\n-   BereqHeader    X-Varnish: 341\r\n-   BereqHeader    Connection: close\r\n-   VCL_call       PIPE\r\n-   BereqUnset     Connection: close\r\n-   BereqUnset     Connection: close\r\n-   BereqHeader    Connection: close\r\n-   VCL_return     pipe\r\n-   BackendOpen    14 default(172.16.220.131,,889) 172.16.220.131 47315 \r\n-   Backend        14 default default(172.16.220.131,,889)\r\n-   BackendClose   14 default(172.16.220.131,,889)\r\n-   BereqAcct      0 0 0 0 0 0\r\n-   End            \r\n\r\n*   << Request  >> 341       \r\n-   Begin          req 340 rxreq\r\n-   Timestamp      Start: 1452622475.604161 0.000000 0.000000\r\n-   Timestamp      Req: 1452622475.604161 0.000000 0.000000\r\n-   ReqStart       172.16.220.131 50587\r\n-   ReqMethod      GET\r\n-   ReqURL         /js/solrsearch/autocomplete.css\r\n-   ReqProtocol    HTTP/1.1\r\n-   ReqHeader      Host: newtest.recambios.eurofred.es\r\n-   ReqHeader      User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:43.0) Gecko/20100101 Firefox/43.0\r\n-   ReqHeader      Accept: text/css,*/*;q=0.1\r\n-   ReqHeader      Accept-Language: es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3\r\n-   ReqHeader      Accept-Encoding: gzip, deflate\r\n-   ReqHeader      Referer: http://newtest.recambios.eurofred.es/\r\n-   ReqHeader      Cookie: __utma=183355301.1729828039.1444184838.1444866271.1444930477.3; __utmz=183355301.1444184838.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _ga=GA1.2.1729828039.1444184838; __utma=23327662.1729828039.1444184838.1447635484.1451440183.20; __utmz\r\n-   ReqHeader      Authorization: Basic ZGVtbzpFdXJvZnJlZFByZTIwMTU=\r\n-   ReqHeader      Cache-Control: max-age=0\r\n-   ReqHeader      X-Forwarded-For: 10.99.0.42\r\n-   ReqHeader      Connection: close\r\n-   ReqUnset       X-Forwarded-For: 10.99.0.42\r\n-   ReqHeader      X-Forwarded-For: 10.99.0.42, 172.16.220.131\r\n-   VCL_call       RECV\r\n-   ReqUnset       X-Forwarded-For: 10.99.0.42, 172.16.220.131\r\n-   ReqHeader      X-Forwarded-For: 10.99.0.42, 172.16.220.131, 172.16.220.131\r\n-   VCL_return     pipe\r\n-   VCL_call       HASH\r\n-   VCL_return     lookup\r\n-   Link           bereq 342 pipe\r\n-   Timestamp      Pipe: 1452622475.604371 0.000209 0.000209\r\n-   Timestamp      PipeSess: 1452622475.607891 0.003729 0.003520\r\n-   PipeAcct       937 985 0 1543\r\n-   End            \r\n\r\n*   << Session  >> 340       \r\n-   Begin          sess 0 HTTP/1\r\n-   SessOpen       172.16.220.131 50587 172.16.220.131:81 172.16.220.131 81 1452622475.604064 12\r\n-   Link           req 341 rxreq\r\n-   SessClose      TX_PIPE 0.004\r\n-   End            \r\n\r\n*   << BeReq    >> 98928     \r\n-   Begin          bereq 98927 pipe\r\n-   BereqMethod    GET\r\n-   BereqURL       /skin/frontend/base/default/css/mirasvit/seositemap/sitemap.css\r\n-   BereqProtocol  HTTP/1.1\r\n-   BereqHeader    Host: newtest.recambios.eurofred.es\r\n-   BereqHeader    User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:43.0) Gecko/20100101 Firefox/43.0\r\n-   BereqHeader    Accept: text/css,*/*;q=0.1\r\n-   BereqHeader    Accept-Language: es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3\r\n-   BereqHeader    Accept-Encoding: gzip, deflate\r\n-   BereqHeader    Referer: http://newtest.recambios.eurofred.es/\r\n-   BereqHeader    Cookie: __utma=183355301.1729828039.1444184838.1444866271.1444930477.3; __utmz=183355301.1444184838.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _ga=GA1.2.1729828039.1444184838; __utma=23327662.1729828039.1444184838.1447635484.1451440183.20; __utmz\r\n-   BereqHeader    Authorization: Basic ZGVtbzpFdXJvZnJlZFByZTIwMTU=\r\n-   BereqHeader    Cache-Control: max-age=0\r\n-   BereqHeader    Connection: close\r\n-   BereqHeader    X-Forwarded-For: 10.99.0.42, 172.16.220.131, 172.16.220.131\r\n-   BereqHeader    X-Varnish: 98927\r\n-   BereqHeader    Connection: close\r\n-   VCL_call       PIPE\r\n-   BereqUnset     Connection: close\r\n-   BereqUnset     Connection: close\r\n-   BereqHeader    Connection: close\r\n-   VCL_return     pipe\r\n-   BackendOpen    19 default(172.16.220.131,,889) 172.16.220.131 47325 \r\n-   Backend        19 default default(172.16.220.131,,889)\r\n-   BackendClose   19 default(172.16.220.131,,889)\r\n-   BereqAcct      0 0 0 0 0 0\r\n-   End            \r\n\r\nAs it shows, all petitions are piping , so not passing through varnish \"magic\".\r\n\r\nI have tested all turpentine configs ( enabling ajax, disabling, and system debug shows nothing ):\r\n\r\n2016-01-12T17:50:48+00:00 DEBUG (7): TURPENTINE: Cleared ESI cache for client (546dnnaam5dbsnk4pgejghpgc3) on event: core_session_abstract_add_message\r\n2016-01-12T17:52:29+00:00 DEBUG (7): TURPENTINE: Cleared ESI cache for client (546dnnaam5dbsnk4pgejghpgc3) on event: core_session_abstract_add_message\r\n2016-01-12T18:09:07+00:00 DEBUG (7): TURPENTINE: Cleared ESI cache for client (546dnnaam5dbsnk4pgejghpgc3) on event: core_session_abstract_add_message\r\n\r\nAny clue ? Thank-you all"},"comment":{"url":"https://api.github.com/repos/nexcess/magento-turpentine/issues/comments/171001882","html_url":"https://github.com/nexcess/magento-turpentine/issues/1071#issuecomment-171001882","issue_url":"https://api.github.com/repos/nexcess/magento-turpentine/issues/1071","id":171001882,"user":{"login":"miguelbalparda","id":3997682,"avatar_url":"https://avatars.githubusercontent.com/u/3997682?v=3","gravatar_id":"","url":"https://api.github.com/users/miguelbalparda","html_url":"https://github.com/miguelbalparda","followers_url":"https://api.github.com/users/miguelbalparda/followers","following_url":"https://api.github.com/users/miguelbalparda/following{/other_user}","gists_url":"https://api.github.com/users/miguelbalparda/gists{/gist_id}","starred_url":"https://api.github.com/users/miguelbalparda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miguelbalparda/subscriptions","organizations_url":"https://api.github.com/users/miguelbalparda/orgs","repos_url":"https://api.github.com/users/miguelbalparda/repos","events_url":"https://api.github.com/users/miguelbalparda/events{/privacy}","received_events_url":"https://api.github.com/users/miguelbalparda/received_events","type":"User","site_admin":false},"created_at":"2016-01-12T18:23:18Z","updated_at":"2016-01-12T18:23:18Z","body":"What makes you think this is a Turpentine issue if you have this running in multiple other sites with the same code? I would go for something different in the environment you are using or the values you are using for backend servers, ports, etc."}}