nexcess / magento-turpentine

A Varnish extension for Magento.
GNU General Public License v2.0
520 stars 252 forks source link

Magento + Varnish + Turpentine and the cart doesn't work #1319

Closed ivantnt closed 7 years ago

ivantnt commented 7 years ago

Hello i'm using Magento 1.9.1, Varnish 4.0 and, Turpentine 0.7.1

I have a problem with the cart. Infact the cart shows products that have been added by different users in different pc and this happens some times by visiting some page.

If i disable Varnish the web site work fine.

Can someone try to help me understand why this happens?

Thank you very much

miguelbalparda commented 7 years ago

There are quite a few possible explanations, but I suggest you checking for the open and closed + the wiki issues in this repo to see if any of the problems described there matches the one you are having. My best guess is a problem in the way your cart blocks are being declared and/or a mix between private and public caching.

ivantnt commented 7 years ago

I try to check again but i have already checked, there is some issue related to the cart but not like mine, i tryed but nothing solved my problem.

If you or someone else have some other idea/solution please tell me

miguelbalparda commented 7 years ago

Well, most of the issues are quite similar to the one you are experiencing. Have you read about the difference between caching a block as public or private? That should help fixing the issue where users are seeing other users cart.

ivantnt commented 7 years ago

No i didn't read about this, where i can find this explanation in FAQ section of Wiki?

miguelbalparda commented 7 years ago

Give this and this a full read. Also, please keep in mind this is not a plug and play extension, you might need to do some changes to your theme layout to make it work with Turpentine.

ivantnt commented 7 years ago

Thank you Miguel now i try to to read, the same happens also with RWD theme

miguelbalparda commented 7 years ago

Can you try using another version of the extension to see if the same happens? 0.7.0 should work

ivantnt commented 7 years ago

No i will try immediatly, where i can download previous version?

miguelbalparda commented 7 years ago

https://github.com/nexcess/magento-turpentine/releases

ivantnt commented 7 years ago

Hello, the problem seems to be solved directly by my provider in Varnish configuration, he told me he has adjusted some necessary cookies as well as cache settings

miguelbalparda commented 7 years ago

@ivantnt can you paste your current VCL here? I'd like to see which changes were made.

ivantnt commented 7 years ago

This is my VCL. Do you see some important changes they made?

vcl 4.0;
C{
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <pthread.h>
static pthread_mutex_t lrand_mutex = PTHREAD_MUTEX_INITIALIZER;
void generate_uuid(char* buf) {
pthread_mutex_lock(&lrand_mutex);
long a = lrand48();
long b = lrand48();
long c = lrand48();
long d = lrand48();
pthread_mutex_unlock(&lrand_mutex);
sprintf(buf, "frontend=%08lx%04lx%04lx%04lx%04lx%08lx",
a,
b & 0xffff,
(b & ((long)0x0fff0000) >> 16) | 0x4000,
(c & 0x0fff) | 0x8000,
(c & (long)0xffff0000) >> 16,
d
);
return;
}
}C
import std;
import directors;
backend default {
.host = "127.0.0.1";
.port = "8081";
.first_byte_timeout = 300s;
.between_bytes_timeout = 300s;
}
backend admin {
.host = "127.0.0.1";
.port = "8081";
.first_byte_timeout = 21600s;
.between_bytes_timeout = 21600s;
}
acl crawler_acl {
"127.0.0.1";
}
acl debug_acl {
}
/* -- REMOVED
sub generate_session {
if (req.url ~ ".*[&?]SID=([^&]+).*") {
set req.http.X-Varnish-Faked-Session = regsub(
req.url, ".*[&?]SID=([^&]+).*", "frontend=\1");
} else {
C{
char uuid_buf [50];
generate_uuid(uuid_buf);
static const struct gethdr_s VGC_HDR_REQ_VARNISH_FAKED_SESSION =
{ HDR_REQ, "\030X-Varnish-Faked-Session:"};
VRT_SetHdr(ctx,
&VGC_HDR_REQ_VARNISH_FAKED_SESSION,
uuid_buf,
vrt_magic_string_end
);
}C
}
if (req.http.Cookie) {
std.collect(req.http.Cookie);
set req.http.Cookie = req.http.X-Varnish-Faked-Session +
"; " + req.http.Cookie;
} else {
set req.http.Cookie = req.http.X-Varnish-Faked-Session;
}
}
sub generate_session_expires {
C{
time_t now = time(NULL);
struct tm now_tm = *gmtime(&now);
now_tm.tm_sec += 3600;
mktime(&now_tm);
char date_buf [50];
strftime(date_buf, sizeof(date_buf)-1, "%a, %d-%b-%Y %H:%M:%S %Z", &now_tm);
static const struct gethdr_s VGC_HDR_RESP_COOKIE_EXPIRES =
{ HDR_RESP, "\031X-Varnish-Cookie-Expires:"};
VRT_SetHdr(ctx,
&VGC_HDR_RESP_COOKIE_EXPIRES,
date_buf,
vrt_magic_string_end
);
}C
}
-- */
sub vcl_synth {
if (resp.status == 750) {
set resp.status = 301;
set resp.http.Location = "https://" + req.http.host + req.url;
return(deliver);
}
}
sub vcl_init {
}
sub vcl_recv {
if (req.restarts == 0) {
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 (!true || req.http.Authorization ||
req.method !~ "^(GET|HEAD|OPTIONS)$" ||
req.http.Cookie ~ "varnish_bypass=1") {
return (pass);
}
if(false) {
set req.http.X-Varnish-Origin-Url = req.url;
}
set req.url = regsuball(req.url, "(.*)//+(.*)", "\1/\2");
if (req.http.Accept-Encoding) {
if (req.http.Accept-Encoding ~ "\*|gzip") {
set req.http.Accept-Encoding = "gzip";
} else if (req.http.Accept-Encoding ~ "deflate") {
set req.http.Accept-Encoding = "deflate";
} else {
unset req.http.Accept-Encoding;
}
}
if (req.url ~ "^(/media/|/skin/|/js/|/)(?:(?:index|litespeed)\.php/)?") {
set req.http.X-Turpentine-Secret-Handshake = "1";
if (req.url ~ "^(/media/|/skin/|/js/|/)(?:(?:index|litespeed)\.php/)?admin-my-shop") {
set req.backend_hint = admin;
return (pipe);
} else {
}
if (req.http.Cookie ~ "\bcurrency=") {
set req.http.X-Varnish-Currency = regsub(
req.http.Cookie, ".*\bcurrency=([^;]*).*", "\1");
}
if (req.http.Cookie ~ "\bstore=") {
set req.http.X-Varnish-Store = regsub(
req.http.Cookie, ".*\bstore=([^;]*).*", "\1");
}
if (req.url ~ "/turpentine/esi/get(?:Block|FormKey)/") {
set req.http.X-Varnish-Esi-Method = regsub(
req.url, ".*/method/(\w+)/.*", "\1");
set req.http.X-Varnish-Esi-Access = regsub(
req.url, ".*/access/(\w+)/.*", "\1");
if (req.http.X-Varnish-Esi-Method == "esi" && req.esi_level == 0 &&
!(false || client.ip ~ debug_acl)) {
return (synth(403, "External ESI requests are not allowed"));
}
}
if (req.http.Cookie !~ "frontend=" && !req.http.X-Varnish-Esi-Method) {
if (client.ip ~ crawler_acl ||
req.http.User-Agent ~ "^(?:ApacheBench/.*|.*Googlebot.*|JoeDog/.*Siege.*|magespeedtest\.com|Nexcessnet_Turpentine/.*|.*PTST.*)$") {
set req.http.Cookie = "frontend=crawler-session";
} else {
return (pipe);
}
}
if (true &&
req.url ~ ".*\.(?:css|js|jpe?g|png|gif|ico|swf)(?=\?|&|$)") {
unset req.http.Cookie;
unset req.http.X-Varnish-Faked-Session;
set req.http.X-Varnish-Static = 1;
return (hash);
}
if (req.url ~ "^(/media/|/skin/|/js/|/)(?:(?:index|litespeed)\.php/)?(?:admin-my-shop|api|cron\.php)" ||
req.url ~ "\?.*__from_store=") {
return (pipe);
}
if (true &&
req.url ~ "(?:[?&](?:__SID|XDEBUG_PROFILE)(?=[&=]|$))") {
return (pass);
}
if (req.url ~ "[?&](utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=") {
set req.url = regsuball(req.url, "(?:(\?)?|&)(?:utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=[^&]+", "\1");
set req.url = regsuball(req.url, "(?:(\?)&|\?$)", "\1");
}
if (true && req.url ~ "[?&](utm_source|utm_medium|utm_campaign|utm_content|utm_term|gclid|cx|ie|cof|siteurl)=") {
set req.url = regsuball(req.url, "(?:(\?)?|&)(?:utm_source|utm_medium|utm_campaign|utm_content|utm_term|gclid|cx|ie|cof|siteurl)=[^&]+", "\1");
set req.url = regsuball(req.url, "(?:(\?)&|\?$)", "\1");
}
if(false) {
set req.http.X-Varnish-Cache-Url = req.url;
set req.url = req.http.X-Varnish-Origin-Url;
unset req.http.X-Varnish-Origin-Url;
}
return (hash);
}
}
sub vcl_pipe {
unset bereq.http.X-Turpentine-Secret-Handshake;
set bereq.http.Connection = "close";
}
sub vcl_hash {
std.log("vcl_hash start");
if (false && req.http.X-Varnish-Static) {
std.log("hash_data static file - req.url: " + req.url);
hash_data(req.url);
if (req.http.Accept-Encoding) {
std.log("hash_data static file - Accept-Encoding: " + req.http.Accept-Encoding);
hash_data(req.http.Accept-Encoding);
}
std.log("vcl_hash end return lookup");
return (lookup);
}
if(false && req.http.X-Varnish-Cache-Url) {
hash_data(req.http.X-Varnish-Cache-Url);
std.log("hash_data - X-Varnish-Cache-Url: " + req.http.X-Varnish-Cache-Url);
} else {
hash_data(req.url);
std.log("hash_data - req.url: " + req.url );
}
if (req.http.Host) {
hash_data(req.http.Host);
std.log("hash_data - req.http.Host: " + req.http.Host);
} else {
hash_data(server.ip);
}
std.log("hash_data - req.http.Ssl-Offloaded: " + req.http.Ssl-Offloaded);
hash_data(req.http.Ssl-Offloaded);
if (req.http.X-Normalized-User-Agent) {
hash_data(req.http.X-Normalized-User-Agent);
std.log("hash_data - req.http.X-Normalized-User-Agent: " + req.http.X-Normalized-User-Agent);
}
if (req.http.Accept-Encoding) {
hash_data(req.http.Accept-Encoding);
std.log("hash_data - req.http.Accept-Encoding: " + req.http.Accept-Encoding);
}
if (req.http.X-Varnish-Store || req.http.X-Varnish-Currency) {
hash_data("s=" + req.http.X-Varnish-Store + "&c=" + req.http.X-Varnish-Currency);
std.log("hash_data - Store and Currency: " + "s=" + req.http.X-Varnish-Store + "&c=" + req.http.X-Varnish-Currency);
}
if (req.http.X-Varnish-Esi-Access == "private" &&
req.http.Cookie ~ "frontend=") {
std.log("hash_data - frontned cookie: " + regsub(req.http.Cookie, "^.*?frontend=([^;]*);*.*$", "\1"));
hash_data(regsub(req.http.Cookie, "^.*?frontend=([^;]*);*.*$", "\1"));
}
<<<<<<< HEAD
std.log("vcl_hash end return lookup");
=======
if (req.http.X-Varnish-Esi-Access == "customer_group" &&
req.http.Cookie ~ "customer_group=") {
hash_data(regsub(req.http.Cookie, "^.*?customer_group=([^;]*);*.*$", "\1"));
}
>>>>>>> master
return (lookup);
}
sub vcl_hit {
}
sub vcl_backend_response {
set beresp.grace = 15s;
set beresp.http.X-Varnish-Host = bereq.http.host;
set beresp.http.X-Varnish-URL = bereq.url;
if (bereq.url ~ "^(/media/|/skin/|/js/|/)(?:(?:index|litespeed)\.php/)?") {
unset beresp.http.Vary;
set beresp.do_gzip = true;
if (beresp.status != 200 && beresp.status != 404) {
set beresp.ttl = 15s;
set beresp.uncacheable = true;
return (deliver);
} else {
if (beresp.http.Set-Cookie) {
set beresp.http.X-Varnish-Set-Cookie = beresp.http.Set-Cookie;
unset beresp.http.Set-Cookie;
}
unset beresp.http.Cache-Control;
unset beresp.http.Expires;
unset beresp.http.Pragma;
unset beresp.http.Cache;
unset beresp.http.Age;
if (beresp.http.X-Turpentine-Esi == "1") {
set beresp.do_esi = true;
}
if (beresp.http.X-Turpentine-Cache == "0") {
set beresp.ttl = 15s;
set beresp.uncacheable = true;
return (deliver);
} else {
if (true &&
bereq.url ~ ".*\.(?:css|js|jpe?g|png|gif|ico|swf)(?=\?|&|$)") {
set beresp.ttl = 28800s;
set beresp.http.Cache-Control = "max-age=28800";
} elseif (bereq.http.X-Varnish-Esi-Method) {
if (bereq.http.X-Varnish-Esi-Access == "private" &&
bereq.http.Cookie ~ "frontend=") {
set beresp.http.X-Varnish-Session = regsub(bereq.http.Cookie,
"^.*?frontend=([^;]*);*.*$", "\1");
}
if (bereq.http.X-Varnish-Esi-Method == "ajax" &&
bereq.http.X-Varnish-Esi-Access == "public") {
set beresp.http.Cache-Control = "max-age=" + regsub(
bereq.url, ".*/ttl/(\d+)/.*", "\1");
}
set beresp.ttl = std.duration(
regsub(
bereq.url, ".*/ttl/(\d+)/.*", "\1s"),
300s);
if (beresp.ttl == 0s) {
set beresp.ttl = 15s;
set beresp.uncacheable = true;
return (deliver);
}
} else {
set beresp.ttl = 3600s;
}
}
}
return (deliver);
}
}
sub vcl_deliver {
if (req.http.X-Varnish-Faked-Session) {
set resp.http.Set-Cookie = req.http.X-Varnish-Faked-Session +
"; expires=" + resp.http.X-Varnish-Cookie-Expires + "; path=/";
if (req.http.Host) {
if (req.http.User-Agent ~ "^(?:ApacheBench/.*|.*Googlebot.*|JoeDog/.*Siege.*|magespeedtest\.com|Nexcessnet_Turpentine/.*|.*PTST.*)$") {
set resp.http.Set-Cookie = resp.http.Set-Cookie +
"; domain=" + regsub(req.http.Host, ":\d+$", "");
} else {
if (req.http.Host ~ "" && "" ~ "..") {
set resp.http.Set-Cookie = resp.http.Set-Cookie +
"; domain=";
} else {
set resp.http.Set-Cookie = resp.http.Set-Cookie +
"; domain=" + regsub(req.http.Host, ":\d+$", "");
}
}
}
set resp.http.Set-Cookie = resp.http.Set-Cookie + "; httponly";
unset resp.http.X-Varnish-Cookie-Expires;
}
if (req.http.X-Varnish-Esi-Method == "ajax" && req.http.X-Varnish-Esi-Access == "private") {
set resp.http.Cache-Control = "no-cache";
}
if (false || client.ip ~ debug_acl) {
set resp.http.X-Varnish-Hits = obj.hits;
set resp.http.X-Varnish-Esi-Method = req.http.X-Varnish-Esi-Method;
set resp.http.X-Varnish-Esi-Access = req.http.X-Varnish-Esi-Access;
set resp.http.X-Varnish-Currency = req.http.X-Varnish-Currency;
set resp.http.X-Varnish-Store = req.http.X-Varnish-Store;
} else {
unset resp.http.X-Varnish;
unset resp.http.Via;
unset resp.http.X-Powered-By;
unset resp.http.Server;
unset resp.http.X-Turpentine-Cache;
unset resp.http.X-Turpentine-Esi;
unset resp.http.X-Turpentine-Flush-Events;
unset resp.http.X-Turpentine-Block;
unset resp.http.X-Varnish-Session;
unset resp.http.X-Varnish-Host;
unset resp.http.X-Varnish-URL;
unset resp.http.X-Varnish-Set-Cookie;
}
}
ivantnt commented 7 years ago

Hello Migel,

i reply also here to you because i saw that you closed the post. This is my vcl, do you see some important changes?

vcl 4.0; C{

include

include

include

include

static pthread_mutex_t lrand_mutex = PTHREAD_MUTEX_INITIALIZER; void generate_uuid(char* buf) { pthread_mutex_lock(&lrand_mutex); long a = lrand48(); long b = lrand48(); long c = lrand48(); long d = lrand48(); pthread_mutex_unlock(&lrand_mutex); sprintf(buf, "frontend=%08lx%04lx%04lx%04lx%04lx%08lx", a, b & 0xffff, (b & ((long)0x0fff0000) >> 16) 0x4000, (c & 0x0fff) 0x8000, (c & (long)0xffff0000) >> 16, d ); return; } }C import std; import directors; backend default { .host = "127.0.0.1"; .port = "8081"; .first_byte_timeout = 300s; .between_bytes_timeout = 300s; } backend admin { .host = "127.0.0.1"; .port = "8081"; .first_byte_timeout = 21600s; .between_bytes_timeout = 21600s; } acl crawler_acl { "127.0.0.1"; } acl debug_acl { } / -- REMOVED sub generate_session { if (req.url ~ ".[&?]SID=([^&]+).") { set req.http.X-Varnish-Faked-Session = regsub( req.url, ".[&?]SID=([^&]+).", "frontend=\1"); } else { C{ char uuid_buf [50]; generate_uuid(uuid_buf); static const struct gethdr_s VGC_HDR_REQ_VARNISH_FAKED_SESSION = { HDR_REQ, "\030X-Varnish-Faked-Session:"}; VRT_SetHdr(ctx, &VGC_HDR_REQ_VARNISH_FAKED_SESSION, uuid_buf, vrt_magic_string_end ); }C } if (req.http.Cookie) { std.collect(req.http.Cookie); set req.http.Cookie = req.http.X-Varnish-Faked-Session + "; " + req.http.Cookie; } else { set req.http.Cookie = req.http.X-Varnish-Faked-Session; } } sub generate_session_expires { C{ time_t now = time(NULL); struct tm now_tm = gmtime(&now); now_tm.tm_sec += 3600; mktime(&now_tm); char date_buf [50]; strftime(date_buf, sizeof(date_buf)-1, "%a, %d-%b-%Y %H:%M:%S %Z", &now_tm); static const struct gethdr_s VGC_HDR_RESP_COOKIE_EXPIRES = { HDR_RESP, "\031X-Varnish-Cookie-Expires:"}; VRT_SetHdr(ctx, &VGC_HDR_RESP_COOKIE_EXPIRES, date_buf, vrt_magic_string_end ); }C } -- */ sub vcl_synth { if (resp.status == 750) { set resp.status = 301; set resp.http.Location = "https://" + req.http.host + req.url; return(deliver); } } sub vcl_init { } sub vcl_recv { if (req.restarts == 0) { 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 (!true req.http.Authorization req.method !~ "^(GET HEAD OPTIONS)$" req.http.Cookie ~ "varnish_bypass=1") { return (pass); } if(false) { set req.http.X-Varnish-Origin-Url = req.url; } set req.url = regsuball(req.url, "(.)//+(.)", "\1/\2"); if (req.http.Accept-Encoding) { if (req.http.Accept-Encoding ~ "* gzip") { set req.http.Accept-Encoding = "gzip"; } else if (req.http.Accept-Encoding ~ "deflate") { set req.http.Accept-Encoding = "deflate"; } else { unset req.http.Accept-Encoding; } } if (req.url ~ "^(/media/ /skin/ /js/ /)(?:(?:index litespeed).php/)?") { set req.http.X-Turpentine-Secret-Handshake = "1"; if (req.url ~ "^(/media/ /skin/ /js/ /)(?:(?:index litespeed).php/)?admin-my-shop") { set req.backend_hint = admin; return (pipe); } else { } if (req.http.Cookie ~ "\bcurrency=") { set req.http.X-Varnish-Currency = regsub( req.http.Cookie, ".\bcurrency=([^;]).", "\1"); } if (req.http.Cookie ~ "\bstore=") { set req.http.X-Varnish-Store = regsub( req.http.Cookie, ".\bstore=([^;]).", "\1"); } if (req.url ~ "/turpentine/esi/get(?:Block FormKey)/") { set req.http.X-Varnish-Esi-Method = regsub( req.url, "./method/(\w+)/.", "\1"); set req.http.X-Varnish-Esi-Access = regsub( req.url, "./access/(\w+)/.", "\1"); if (req.http.X-Varnish-Esi-Method == "esi" && req.esi_level == 0 && !(false client.ip ~ debug_acl)) { return (synth(403, "External ESI requests are not allowed")); } } if (req.http.Cookie !~ "frontend=" && !req.http.X-Varnish-Esi-Method) { if (client.ip ~ crawler_acl req.http.User-Agent ~ "^(?:ApacheBench/.* .Googlebot. JoeDog/.Siege. magespeedtest.com Nexcessnet_Turpentine/.* .PTST.)$") { set req.http.Cookie = "frontend=crawler-session"; } else { return (pipe); } } if (true && req.url ~ ".*.(?:css js jpe?g png gif ico swf)(?=\? & $)") { unset req.http.Cookie; unset req.http.X-Varnish-Faked-Session; set req.http.X-Varnish-Static = 1; return (hash); } if (req.url ~ "^(/media/ /skin/ /js/ /)(?:(?:index litespeed).php/)?(?:admin-my-shop api cron.php)"

req.url ~ "\?.__from_store=") { return (pipe); } if (true && req.url ~ "(?:?&(?=[&=]|$))") { return (pass); } if (req.url ~ "?&=") { set req.url = regsuball(req.url, "(?:(\?)?|&)(?:utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=[^&]+", "\1"); set req.url = regsuball(req.url, "(?:(\?)&|\?$)", "\1"); } if (true && req.url ~ "?&=") { set req.url = regsuball(req.url, "(?:(\?)?|&)(?:utm_source|utm_medium|utm_campaign|utm_content|utm_term|gclid|cx|ie|cof|siteurl)=[^&]+", "\1"); set req.url = regsuball(req.url, "(?:(\?)&|\?$)", "\1"); } if(false) { set req.http.X-Varnish-Cache-Url = req.url; set req.url = req.http.X-Varnish-Origin-Url; unset req.http.X-Varnish-Origin-Url; } return (hash); } } sub vcl_pipe { unset bereq.http.X-Turpentine-Secret-Handshake; set bereq.http.Connection = "close"; } sub vcl_hash { std.log("vcl_hash start"); if (false && req.http.X-Varnish-Static) { std.log("hash_data static file - req.url: " + req.url); hash_data(req.url); if (req.http.Accept-Encoding) { std.log("hash_data static file - Accept-Encoding: " + req.http.Accept-Encoding); hash_data(req.http.Accept-Encoding); } std.log("vcl_hash end return lookup"); return (lookup); } if(false && req.http.X-Varnish-Cache-Url) { hash_data(req.http.X-Varnish-Cache-Url); std.log("hash_data - X-Varnish-Cache-Url: " + req.http.X-Varnish-Cache-Url); } else { hash_data(req.url); std.log("hash_data - req.url: " + req.url ); } if (req.http.Host) { hash_data(req.http.Host); std.log("hash_data - req.http.Host: " + req.http.Host); } else { hash_data(server.ip); } std.log("hash_data - req.http.Ssl-Offloaded: " + req.http.Ssl-Offloaded); hash_data(req.http.Ssl-Offloaded); if (req.http.X-Normalized-User-Agent) { hash_data(req.http.X-Normalized-User-Agent); std.log("hash_data - req.http.X-Normalized-User-Agent: " + req.http.X-Normalized-User-Agent); } if (req.http.Accept-Encoding) { hash_data(req.http.Accept-Encoding); std.log("hash_data - req.http.Accept-Encoding: " + req.http.Accept-Encoding); } if (req.http.X-Varnish-Store || req.http.X-Varnish-Currency) { hash_data("s=" + req.http.X-Varnish-Store + "&c=" + req.http.X-Varnish-Currency); std.log("hash_data - Store and Currency: " + "s=" + req.http.X-Varnish-Store + "&c=" + req.http.X-Varnish-Currency); } if (req.http.X-Varnish-Esi-Access == "private" && req.http.Cookie ~ "frontend=") { std.log("hash_data - frontned cookie: " + regsub(req.http.Cookie, "^.?frontend=([^;]);.$", "\1")); hash_data(regsub(req.http.Cookie, "^.?frontend=([^;]);.*$", "\1")); } <<<<<<< HEAD std.log("vcl_hash end return lookup");

if (req.http.X-Varnish-Esi-Access == "customer_group" && req.http.Cookie ~ "customer_group=") { hash_data(regsub(req.http.Cookie, "^.?customer_group=([^;]);.$", "\1")); }

master return (lookup); } sub vcl_hit { } sub vcl_backend_response { set beresp.grace = 15s; set beresp.http.X-Varnish-Host = bereq.http.host; set beresp.http.X-Varnish-URL = bereq.url; if (bereq.url ~ "^(/media/|/skin/|/js/|/)(?:(?:index|litespeed).php/)?") { unset beresp.http.Vary; set beresp.do_gzip = true; if (beresp.status != 200 && beresp.status != 404) { set beresp.ttl = 15s; set beresp.uncacheable = true; return (deliver); } else { if (beresp.http.Set-Cookie) { set beresp.http.X-Varnish-Set-Cookie = beresp.http.Set-Cookie; unset beresp.http.Set-Cookie; } unset beresp.http.Cache-Control; unset beresp.http.Expires; unset beresp.http.Pragma; unset beresp.http.Cache; unset beresp.http.Age; if (beresp.http.X-Turpentine-Esi == "1") { set beresp.do_esi = true; } if (beresp.http.X-Turpentine-Cache == "0") { set beresp.ttl = 15s; set beresp.uncacheable = true; return (deliver); } else { if (true && bereq.url ~ "..(?:css|js|jpe?g|png|gif|ico|swf)(?=\?|&|$)") { set beresp.ttl = 28800s; set beresp.http.Cache-Control = "max-age=28800"; } elseif (bereq.http.X-Varnish-Esi-Method) { if (bereq.http.X-Varnish-Esi-Access == "private" && bereq.http.Cookie ~ "frontend=") { set beresp.http.X-Varnish-Session = regsub(bereq.http.Cookie, "^.?frontend=([^;]);.$", "\1"); } if (bereq.http.X-Varnish-Esi-Method == "ajax" && bereq.http.X-Varnish-Esi-Access == "public") { set beresp.http.Cache-Control = "max-age=" + regsub( bereq.url, "./ttl/(\d+)/.", "\1"); } set beresp.ttl = std.duration( regsub( bereq.url, "./ttl/(\d+)/.", "\1s"), 300s); if (beresp.ttl == 0s) { set beresp.ttl = 15s; set beresp.uncacheable = true; return (deliver); } } else { set beresp.ttl = 3600s; } } } return (deliver); } } sub vcl_deliver { if (req.http.X-Varnish-Faked-Session) { set resp.http.Set-Cookie = req.http.X-Varnish-Faked-Session + "; expires=" + resp.http.X-Varnish-Cookie-Expires + "; path=/"; if (req.http.Host) { if (req.http.User-Agent ~ "^(?:ApacheBench/.|.Googlebot.|JoeDog/.Siege.|magespeedtest.com|Nexcessnet_Turpentine/.|.PTST.*)$") { set resp.http.Set-Cookie = resp.http.Set-Cookie + "; domain=" + regsub(req.http.Host, ":\d+$", ""); } else { if (req.http.Host ~ "" && "" ~ "..") { set resp.http.Set-Cookie = resp.http.Set-Cookie + "; domain="; } else { set resp.http.Set-Cookie = resp.http.Set-Cookie + "; domain=" + regsub(req.http.Host, ":\d+$", ""); } } } set resp.http.Set-Cookie = resp.http.Set-Cookie + "; httponly"; unset resp.http.X-Varnish-Cookie-Expires; } if (req.http.X-Varnish-Esi-Method == "ajax" && req.http.X-Varnish-Esi-Access == "private") { set resp.http.Cache-Control = "no-cache"; } if (false || client.ip ~ debug_acl) { set resp.http.X-Varnish-Hits = obj.hits; set resp.http.X-Varnish-Esi-Method = req.http.X-Varnish-Esi-Method; set resp.http.X-Varnish-Esi-Access = req.http.X-Varnish-Esi-Access; set resp.http.X-Varnish-Currency = req.http.X-Varnish-Currency; set resp.http.X-Varnish-Store = req.http.X-Varnish-Store; } else { unset resp.http.X-Varnish; unset resp.http.Via; unset resp.http.X-Powered-By; unset resp.http.Server; unset resp.http.X-Turpentine-Cache; unset resp.http.X-Turpentine-Esi; unset resp.http.X-Turpentine-Flush-Events; unset resp.http.X-Turpentine-Block; unset resp.http.X-Varnish-Session; unset resp.http.X-Varnish-Host; unset resp.http.X-Varnish-URL; unset resp.http.X-Varnish-Set-Cookie; } }

Il 28/11/2016 13:04, Miguel Balparda ha scritto:

@ivantnt https://github.com/ivantnt can you paste your current VCL here? I'd like to see which changes were made.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nexcess/magento-turpentine/issues/1319#issuecomment-263254579, or mute the thread https://github.com/notifications/unsubscribe-auth/AVgKMmUwp63z4HJYpqQ8kye4tFUzV4p-ks5rCsNJgaJpZM4K4G1V.

miguelbalparda commented 7 years ago

Are you sure that's your VCL right now? It has a HEAD and MASTER diff on it.

ivantnt commented 7 years ago

I attach it again.

Inside "Cache management" of Magento i have clicked on "Save Varnish config" and then "Download Varnish config"

Do you is ok?

Il 28/11/2016 14:28, Miguel Balparda ha scritto:

Are you sure that's your VCL right now? It has a HEAD and MASTER diff on it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nexcess/magento-turpentine/issues/1319#issuecomment-263271099, or mute the thread https://github.com/notifications/unsubscribe-auth/AVgKMtmUqy_w3vjOJ8ifHA2a3XLXbpl-ks5rCtcRgaJpZM4K4G1V.

vcl 4.0; C{

include

include

include

include

static pthread_mutex_t lrand_mutex = PTHREAD_MUTEX_INITIALIZER; void generate_uuid(char buf) { pthread_mutex_lock(&lrand_mutex); long a = lrand48(); long b = lrand48(); long c = lrand48(); long d = lrand48(); pthread_mutex_unlock(&lrand_mutex); sprintf(buf, "frontend=%08lx%04lx%04lx%04lx%04lx%08lx", a, b & 0xffff, (b & ((long)0x0fff0000) >> 16) | 0x4000, (c & 0x0fff) | 0x8000, (c & (long)0xffff0000) >> 16, d ); return; } }C import std; import directors; backend default { .host = "127.0.0.1"; .port = "8081"; .first_byte_timeout = 300s; .between_bytes_timeout = 300s; } backend admin { .host = "127.0.0.1"; .port = "8081"; .first_byte_timeout = 21600s; .between_bytes_timeout = 21600s; } acl crawler_acl { "127.0.0.1"; } acl debug_acl { } / -- REMOVED sub generate_session { if (req.url ~ ".[&?]SID=([^&]+).") { set req.http.X-Varnish-Faked-Session = regsub( req.url, ".[&?]SID=([^&]+).", "frontend=\1"); } else { C{ char uuid_buf [50]; generate_uuid(uuid_buf); static const struct gethdr_s VGC_HDR_REQ_VARNISH_FAKED_SESSION = { HDR_REQ, "\030X-Varnish-Faked-Session:"}; VRT_SetHdr(ctx, &VGC_HDR_REQ_VARNISH_FAKED_SESSION, uuid_buf, vrt_magic_string_end ); }C } if (req.http.Cookie) { std.collect(req.http.Cookie); set req.http.Cookie = req.http.X-Varnish-Faked-Session + "; " + req.http.Cookie; } else { set req.http.Cookie = req.http.X-Varnish-Faked-Session; } } sub generate_session_expires { C{ time_t now = time(NULL); struct tm now_tm = gmtime(&now); now_tm.tm_sec += 3600; mktime(&now_tm); char date_buf [50]; strftime(date_buf, sizeof(date_buf)-1, "%a, %d-%b-%Y %H:%M:%S %Z", &now_tm); static const struct gethdr_s VGC_HDR_RESP_COOKIE_EXPIRES = { HDR_RESP, "\031X-Varnish-Cookie-Expires:"}; VRT_SetHdr(ctx, &VGC_HDR_RESP_COOKIE_EXPIRES, date_buf, vrt_magic_string_end ); }C } -- / sub vcl_synth { if (resp.status == 750) { set resp.status = 301; set resp.http.Location = "https://" + req.http.host + req.url; return(deliver); } } sub vcl_init { } sub vcl_recv { if (req.restarts == 0) { 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 (!true || req.http.Authorization || req.method !~ "^(GET|HEAD|OPTIONS)$" || req.http.Cookie ~ "varnish_bypass=1") { return (pass); } if(false) { set req.http.X-Varnish-Origin-Url = req.url; } set req.url = regsuball(req.url, "(.)//+(.)", "\1/\2"); if (req.http.Accept-Encoding) { if (req.http.Accept-Encoding ~ "*|gzip") { set req.http.Accept-Encoding = "gzip"; } else if (req.http.Accept-Encoding ~ "deflate") { set req.http.Accept-Encoding = "deflate"; } else { unset req.http.Accept-Encoding; } } if (req.url ~ "^(/media/|/skin/|/js/|/)(?:(?:index|litespeed).php/)?") { set req.http.X-Turpentine-Secret-Handshake = "1"; if (req.url ~ "^(/media/|/skin/|/js/|/)(?:(?:index|litespeed).php/)?admin-my-shop") { set req.backend_hint = admin; return (pipe); } else { } if (req.http.Cookie ~ "\bcurrency=") { set req.http.X-Varnish-Currency = regsub( req.http.Cookie, ".\bcurrency=([^;]).", "\1"); } if (req.http.Cookie ~ "\bstore=") { set req.http.X-Varnish-Store = regsub( req.http.Cookie, ".\bstore=([^;]).", "\1"); } if (req.url ~ "/turpentine/esi/get(?:Block|FormKey)/") { set req.http.X-Varnish-Esi-Method = regsub( req.url, "./method/(\w+)/.", "\1"); set req.http.X-Varnish-Esi-Access = regsub( req.url, "./access/(\w+)/.", "\1"); if (req.http.X-Varnish-Esi-Method == "esi" && req.esi_level == 0 && !(false || client.ip ~ debug_acl)) { return (synth(403, "External ESI requests are not allowed")); } } if (req.http.Cookie !~ "frontend=" && !req.http.X-Varnish-Esi-Method) { if (client.ip ~ crawler_acl || req.http.User-Agent ~ "^(?:ApacheBench/.|.Googlebot.|JoeDog/.Siege.|magespeedtest.com|Nexcessnet_Turpentine/.|.PTST.)$") { set req.http.Cookie = "frontend=crawler-session"; } else { return (pipe); } } if (true && req.url ~ "..(?:css|js|jpe?g|png|gif|ico|swf)(?=\?|&|$)") { unset req.http.Cookie; unset req.http.X-Varnish-Faked-Session; set req.http.X-Varnish-Static = 1; return (hash); } if (req.url ~ "^(/media/|/skin/|/js/|/)(?:(?:index|litespeed).php/)?(?:admin-my-shop|api|cron.php)" || req.url ~ "\?.__from_store=") { return (pipe); } if (true && req.url ~ "(?:?&(?=[&=]|$))") { return (pass); } if (req.url ~ "?&=") { set req.url = regsuball(req.url, "(?:(\?)?|&)(?:utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=[^&]+", "\1"); set req.url = regsuball(req.url, "(?:(\?)&|\?$)", "\1"); } if (true && req.url ~ "?&=") { set req.url = regsuball(req.url, "(?:(\?)?|&)(?:utm_source|utm_medium|utm_campaign|utm_content|utm_term|gclid|cx|ie|cof|siteurl)=[^&]+", "\1"); set req.url = regsuball(req.url, "(?:(\?)&|\?$)", "\1"); } if(false) { set req.http.X-Varnish-Cache-Url = req.url; set req.url = req.http.X-Varnish-Origin-Url; unset req.http.X-Varnish-Origin-Url; } return (hash); } } sub vcl_pipe { unset bereq.http.X-Turpentine-Secret-Handshake; set bereq.http.Connection = "close"; } sub vcl_hash { std.log("vcl_hash start"); if (false && req.http.X-Varnish-Static) { std.log("hash_data static file - req.url: " + req.url); hash_data(req.url); if (req.http.Accept-Encoding) { std.log("hash_data static file - Accept-Encoding: " + req.http.Accept-Encoding); hash_data(req.http.Accept-Encoding); } std.log("vcl_hash end return lookup"); return (lookup); } if(false && req.http.X-Varnish-Cache-Url) { hash_data(req.http.X-Varnish-Cache-Url); std.log("hash_data - X-Varnish-Cache-Url: " + req.http.X-Varnish-Cache-Url); } else { hash_data(req.url); std.log("hash_data - req.url: " + req.url ); } if (req.http.Host) { hash_data(req.http.Host); std.log("hash_data - req.http.Host: " + req.http.Host); } else { hash_data(server.ip); } std.log("hash_data - req.http.Ssl-Offloaded: " + req.http.Ssl-Offloaded); hash_data(req.http.Ssl-Offloaded); if (req.http.X-Normalized-User-Agent) { hash_data(req.http.X-Normalized-User-Agent); std.log("hash_data - req.http.X-Normalized-User-Agent: " + req.http.X-Normalized-User-Agent); } if (req.http.Accept-Encoding) { hash_data(req.http.Accept-Encoding); std.log("hash_data - req.http.Accept-Encoding: " + req.http.Accept-Encoding); } if (req.http.X-Varnish-Store || req.http.X-Varnish-Currency) { hash_data("s=" + req.http.X-Varnish-Store + "&c=" + req.http.X-Varnish-Currency); std.log("hash_data - Store and Currency: " + "s=" + req.http.X-Varnish-Store + "&c=" + req.http.X-Varnish-Currency); } if (req.http.X-Varnish-Esi-Access == "private" && req.http.Cookie ~ "frontend=") { std.log("hash_data - frontned cookie: " + regsub(req.http.Cookie, "^.?frontend=([^;]);.$", "\1")); hash_data(regsub(req.http.Cookie, "^.?frontend=([^;]);.$", "\1")); } <<<<<<< HEAD std.log("vcl_hash end return lookup");

if (req.http.X-Varnish-Esi-Access == "customer_group" && req.http.Cookie ~ "customer_group=") { hash_data(regsub(req.http.Cookie, "^.?customer_group=([^;]);.$", "\1")); }

master return (lookup); } sub vcl_hit { } sub vcl_backend_response { set beresp.grace = 15s; set beresp.http.X-Varnish-Host = bereq.http.host; set beresp.http.X-Varnish-URL = bereq.url; if (bereq.url ~ "^(/media/|/skin/|/js/|/)(?:(?:index|litespeed).php/)?") { unset beresp.http.Vary; set beresp.do_gzip = true; if (beresp.status != 200 && beresp.status != 404) { set beresp.ttl = 15s; set beresp.uncacheable = true; return (deliver); } else { if (beresp.http.Set-Cookie) { set beresp.http.X-Varnish-Set-Cookie = beresp.http.Set-Cookie; unset beresp.http.Set-Cookie; } unset beresp.http.Cache-Control; unset beresp.http.Expires; unset beresp.http.Pragma; unset beresp.http.Cache; unset beresp.http.Age; if (beresp.http.X-Turpentine-Esi == "1") { set beresp.do_esi = true; } if (beresp.http.X-Turpentine-Cache == "0") { set beresp.ttl = 15s; set beresp.uncacheable = true; return (deliver); } else { if (true && bereq.url ~ "..(?:css|js|jpe?g|png|gif|ico|swf)(?=\?|&|$)") { set beresp.ttl = 28800s; set beresp.http.Cache-Control = "max-age=28800"; } elseif (bereq.http.X-Varnish-Esi-Method) { if (bereq.http.X-Varnish-Esi-Access == "private" && bereq.http.Cookie ~ "frontend=") { set beresp.http.X-Varnish-Session = regsub(bereq.http.Cookie, "^.?frontend=([^;]);.$", "\1"); } if (bereq.http.X-Varnish-Esi-Method == "ajax" && bereq.http.X-Varnish-Esi-Access == "public") { set beresp.http.Cache-Control = "max-age=" + regsub( bereq.url, "./ttl/(\d+)/.", "\1"); } set beresp.ttl = std.duration( regsub( bereq.url, "./ttl/(\d+)/.", "\1s"), 300s); if (beresp.ttl == 0s) { set beresp.ttl = 15s; set beresp.uncacheable = true; return (deliver); } } else { set beresp.ttl = 3600s; } } } return (deliver); } } sub vcl_deliver { if (req.http.X-Varnish-Faked-Session) { set resp.http.Set-Cookie = req.http.X-Varnish-Faked-Session + "; expires=" + resp.http.X-Varnish-Cookie-Expires + "; path=/"; if (req.http.Host) { if (req.http.User-Agent ~ "^(?:ApacheBench/.|.Googlebot.|JoeDog/.Siege.|magespeedtest.com|Nexcessnet_Turpentine/.|.PTST.*)$") { set resp.http.Set-Cookie = resp.http.Set-Cookie + "; domain=" + regsub(req.http.Host, ":\d+$", ""); } else { if (req.http.Host ~ "" && "" ~ "..") { set resp.http.Set-Cookie = resp.http.Set-Cookie + "; domain="; } else { set resp.http.Set-Cookie = resp.http.Set-Cookie + "; domain=" + regsub(req.http.Host, ":\d+$", ""); } } } set resp.http.Set-Cookie = resp.http.Set-Cookie + "; httponly"; unset resp.http.X-Varnish-Cookie-Expires; } if (req.http.X-Varnish-Esi-Method == "ajax" && req.http.X-Varnish-Esi-Access == "private") { set resp.http.Cache-Control = "no-cache"; } if (false || client.ip ~ debug_acl) { set resp.http.X-Varnish-Hits = obj.hits; set resp.http.X-Varnish-Esi-Method = req.http.X-Varnish-Esi-Method; set resp.http.X-Varnish-Esi-Access = req.http.X-Varnish-Esi-Access; set resp.http.X-Varnish-Currency = req.http.X-Varnish-Currency; set resp.http.X-Varnish-Store = req.http.X-Varnish-Store; } else { unset resp.http.X-Varnish; unset resp.http.Via; unset resp.http.X-Powered-By; unset resp.http.Server; unset resp.http.X-Turpentine-Cache; unset resp.http.X-Turpentine-Esi; unset resp.http.X-Turpentine-Flush-Events; unset resp.http.X-Turpentine-Block; unset resp.http.X-Varnish-Session; unset resp.http.X-Varnish-Host; unset resp.http.X-Varnish-URL; unset resp.http.X-Varnish-Set-Cookie; } } vcl 4.0; C{

include

include

include

include

static pthread_mutex_t lrand_mutex = PTHREAD_MUTEX_INITIALIZER; void generate_uuid(char buf) { pthread_mutex_lock(&lrand_mutex); long a = lrand48(); long b = lrand48(); long c = lrand48(); long d = lrand48(); pthread_mutex_unlock(&lrand_mutex); sprintf(buf, "frontend=%08lx%04lx%04lx%04lx%04lx%08lx", a, b & 0xffff, (b & ((long)0x0fff0000) >> 16) | 0x4000, (c & 0x0fff) | 0x8000, (c & (long)0xffff0000) >> 16, d ); return; } }C import std; import directors; backend default { .host = "127.0.0.1"; .port = "8081"; .first_byte_timeout = 300s; .between_bytes_timeout = 300s; } backend admin { .host = "127.0.0.1"; .port = "8081"; .first_byte_timeout = 21600s; .between_bytes_timeout = 21600s; } acl crawler_acl { "127.0.0.1"; } acl debug_acl { } / -- REMOVED sub generate_session { if (req.url ~ ".[&?]SID=([^&]+).") { set req.http.X-Varnish-Faked-Session = regsub( req.url, ".[&?]SID=([^&]+).", "frontend=\1"); } else { C{ char uuid_buf [50]; generate_uuid(uuid_buf); static const struct gethdr_s VGC_HDR_REQ_VARNISH_FAKED_SESSION = { HDR_REQ, "\030X-Varnish-Faked-Session:"}; VRT_SetHdr(ctx, &VGC_HDR_REQ_VARNISH_FAKED_SESSION, uuid_buf, vrt_magic_string_end ); }C } if (req.http.Cookie) { std.collect(req.http.Cookie); set req.http.Cookie = req.http.X-Varnish-Faked-Session + "; " + req.http.Cookie; } else { set req.http.Cookie = req.http.X-Varnish-Faked-Session; } } sub generate_session_expires { C{ time_t now = time(NULL); struct tm now_tm = gmtime(&now); now_tm.tm_sec += 3600; mktime(&now_tm); char date_buf [50]; strftime(date_buf, sizeof(date_buf)-1, "%a, %d-%b-%Y %H:%M:%S %Z", &now_tm); static const struct gethdr_s VGC_HDR_RESP_COOKIE_EXPIRES = { HDR_RESP, "\031X-Varnish-Cookie-Expires:"}; VRT_SetHdr(ctx, &VGC_HDR_RESP_COOKIE_EXPIRES, date_buf, vrt_magic_string_end ); }C } -- / sub vcl_synth { if (resp.status == 750) { set resp.status = 301; set resp.http.Location = "https://" + req.http.host + req.url; return(deliver); } } sub vcl_init { } sub vcl_recv { if (req.restarts == 0) { 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 (!true || req.http.Authorization || req.method !~ "^(GET|HEAD|OPTIONS)$" || req.http.Cookie ~ "varnish_bypass=1") { return (pass); } if(false) { set req.http.X-Varnish-Origin-Url = req.url; } set req.url = regsuball(req.url, "(.)//+(.)", "\1/\2"); if (req.http.Accept-Encoding) { if (req.http.Accept-Encoding ~ "*|gzip") { set req.http.Accept-Encoding = "gzip"; } else if (req.http.Accept-Encoding ~ "deflate") { set req.http.Accept-Encoding = "deflate"; } else { unset req.http.Accept-Encoding; } } if (req.url ~ "^(/media/|/skin/|/js/|/)(?:(?:index|litespeed).php/)?") { set req.http.X-Turpentine-Secret-Handshake = "1"; if (req.url ~ "^(/media/|/skin/|/js/|/)(?:(?:index|litespeed).php/)?admin-my-shop") { set req.backend_hint = admin; return (pipe); } else { } if (req.http.Cookie ~ "\bcurrency=") { set req.http.X-Varnish-Currency = regsub( req.http.Cookie, ".\bcurrency=([^;]).", "\1"); } if (req.http.Cookie ~ "\bstore=") { set req.http.X-Varnish-Store = regsub( req.http.Cookie, ".\bstore=([^;]).", "\1"); } if (req.url ~ "/turpentine/esi/get(?:Block|FormKey)/") { set req.http.X-Varnish-Esi-Method = regsub( req.url, "./method/(\w+)/.", "\1"); set req.http.X-Varnish-Esi-Access = regsub( req.url, "./access/(\w+)/.", "\1"); if (req.http.X-Varnish-Esi-Method == "esi" && req.esi_level == 0 && !(false || client.ip ~ debug_acl)) { return (synth(403, "External ESI requests are not allowed")); } } if (req.http.Cookie !~ "frontend=" && !req.http.X-Varnish-Esi-Method) { if (client.ip ~ crawler_acl || req.http.User-Agent ~ "^(?:ApacheBench/.|.Googlebot.|JoeDog/.Siege.|magespeedtest.com|Nexcessnet_Turpentine/.|.PTST.)$") { set req.http.Cookie = "frontend=crawler-session"; } else { return (pipe); } } if (true && req.url ~ "..(?:css|js|jpe?g|png|gif|ico|swf)(?=\?|&|$)") { unset req.http.Cookie; unset req.http.X-Varnish-Faked-Session; set req.http.X-Varnish-Static = 1; return (hash); } if (req.url ~ "^(/media/|/skin/|/js/|/)(?:(?:index|litespeed).php/)?(?:admin-my-shop|api|cron.php)" || req.url ~ "\?.__from_store=") { return (pipe); } if (true && req.url ~ "(?:?&(?=[&=]|$))") { return (pass); } if (req.url ~ "?&=") { set req.url = regsuball(req.url, "(?:(\?)?|&)(?:utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=[^&]+", "\1"); set req.url = regsuball(req.url, "(?:(\?)&|\?$)", "\1"); } if (true && req.url ~ "?&=") { set req.url = regsuball(req.url, "(?:(\?)?|&)(?:utm_source|utm_medium|utm_campaign|utm_content|utm_term|gclid|cx|ie|cof|siteurl)=[^&]+", "\1"); set req.url = regsuball(req.url, "(?:(\?)&|\?$)", "\1"); } if(false) { set req.http.X-Varnish-Cache-Url = req.url; set req.url = req.http.X-Varnish-Origin-Url; unset req.http.X-Varnish-Origin-Url; } return (hash); } } sub vcl_pipe { unset bereq.http.X-Turpentine-Secret-Handshake; set bereq.http.Connection = "close"; } sub vcl_hash { std.log("vcl_hash start"); if (false && req.http.X-Varnish-Static) { std.log("hash_data static file - req.url: " + req.url); hash_data(req.url); if (req.http.Accept-Encoding) { std.log("hash_data static file - Accept-Encoding: " + req.http.Accept-Encoding); hash_data(req.http.Accept-Encoding); } std.log("vcl_hash end return lookup"); return (lookup); } if(false && req.http.X-Varnish-Cache-Url) { hash_data(req.http.X-Varnish-Cache-Url); std.log("hash_data - X-Varnish-Cache-Url: " + req.http.X-Varnish-Cache-Url); } else { hash_data(req.url); std.log("hash_data - req.url: " + req.url ); } if (req.http.Host) { hash_data(req.http.Host); std.log("hash_data - req.http.Host: " + req.http.Host); } else { hash_data(server.ip); } std.log("hash_data - req.http.Ssl-Offloaded: " + req.http.Ssl-Offloaded); hash_data(req.http.Ssl-Offloaded); if (req.http.X-Normalized-User-Agent) { hash_data(req.http.X-Normalized-User-Agent); std.log("hash_data - req.http.X-Normalized-User-Agent: " + req.http.X-Normalized-User-Agent); } if (req.http.Accept-Encoding) { hash_data(req.http.Accept-Encoding); std.log("hash_data - req.http.Accept-Encoding: " + req.http.Accept-Encoding); } if (req.http.X-Varnish-Store || req.http.X-Varnish-Currency) { hash_data("s=" + req.http.X-Varnish-Store + "&c=" + req.http.X-Varnish-Currency); std.log("hash_data - Store and Currency: " + "s=" + req.http.X-Varnish-Store + "&c=" + req.http.X-Varnish-Currency); } if (req.http.X-Varnish-Esi-Access == "private" && req.http.Cookie ~ "frontend=") { std.log("hash_data - frontned cookie: " + regsub(req.http.Cookie, "^.?frontend=([^;]);.$", "\1")); hash_data(regsub(req.http.Cookie, "^.?frontend=([^;]);.$", "\1")); } <<<<<<< HEAD std.log("vcl_hash end return lookup");

if (req.http.X-Varnish-Esi-Access == "customer_group" && req.http.Cookie ~ "customer_group=") { hash_data(regsub(req.http.Cookie, "^.?customer_group=([^;]);.$", "\1")); } master return (lookup); } sub vcl_hit { } sub vcl_backend_response { set beresp.grace = 15s; set beresp.http.X-Varnish-Host = bereq.http.host; set beresp.http.X-Varnish-URL = bereq.url; if (bereq.url ~ "^(/media/|/skin/|/js/|/)(?:(?:index|litespeed).php/)?") { unset beresp.http.Vary; set beresp.do_gzip = true; if (beresp.status != 200 && beresp.status != 404) { set beresp.ttl = 15s; set beresp.uncacheable = true; return (deliver); } else { if (beresp.http.Set-Cookie) { set beresp.http.X-Varnish-Set-Cookie = beresp.http.Set-Cookie; unset beresp.http.Set-Cookie; } unset beresp.http.Cache-Control; unset beresp.http.Expires; unset beresp.http.Pragma; unset beresp.http.Cache; unset beresp.http.Age; if (beresp.http.X-Turpentine-Esi == "1") { set beresp.do_esi = true; } if (beresp.http.X-Turpentine-Cache == "0") { set beresp.ttl = 15s; set beresp.uncacheable = true; return (deliver); } else { if (true && bereq.url ~ "..(?:css|js|jpe?g|png|gif|ico|swf)(?=\?|&|$)") { set beresp.ttl = 28800s; set beresp.http.Cache-Control = "max-age=28800"; } elseif (bereq.http.X-Varnish-Esi-Method) { if (bereq.http.X-Varnish-Esi-Access == "private" && bereq.http.Cookie ~ "frontend=") { set beresp.http.X-Varnish-Session = regsub(bereq.http.Cookie, "^.?frontend=([^;]);.$", "\1"); } if (bereq.http.X-Varnish-Esi-Method == "ajax" && bereq.http.X-Varnish-Esi-Access == "public") { set beresp.http.Cache-Control = "max-age=" + regsub( bereq.url, "./ttl/(\d+)/.", "\1"); } set beresp.ttl = std.duration( regsub( bereq.url, "./ttl/(\d+)/.", "\1s"), 300s); if (beresp.ttl == 0s) { set beresp.ttl = 15s; set beresp.uncacheable = true; return (deliver); } } else { set beresp.ttl = 3600s; } } } return (deliver); } } sub vcl_deliver { if (req.http.X-Varnish-Faked-Session) { set resp.http.Set-Cookie = req.http.X-Varnish-Faked-Session + "; expires=" + resp.http.X-Varnish-Cookie-Expires + "; path=/"; if (req.http.Host) { if (req.http.User-Agent ~ "^(?:ApacheBench/.|.Googlebot.|JoeDog/.Siege.|magespeedtest.com|Nexcessnet_Turpentine/.|.PTST.*)$") { set resp.http.Set-Cookie = resp.http.Set-Cookie + "; domain=" + regsub(req.http.Host, ":\d+$", ""); } else { if (req.http.Host ~ "" && "" ~ "..") { set resp.http.Set-Cookie = resp.http.Set-Cookie + "; domain="; } else { set resp.http.Set-Cookie = resp.http.Set-Cookie + "; domain=" + regsub(req.http.Host, ":\d+$", ""); } } } set resp.http.Set-Cookie = resp.http.Set-Cookie + "; httponly"; unset resp.http.X-Varnish-Cookie-Expires; } if (req.http.X-Varnish-Esi-Method == "ajax" && req.http.X-Varnish-Esi-Access == "private") { set resp.http.Cache-Control = "no-cache"; } if (false || client.ip ~ debug_acl) { set resp.http.X-Varnish-Hits = obj.hits; set resp.http.X-Varnish-Esi-Method = req.http.X-Varnish-Esi-Method; set resp.http.X-Varnish-Esi-Access = req.http.X-Varnish-Esi-Access; set resp.http.X-Varnish-Currency = req.http.X-Varnish-Currency; set resp.http.X-Varnish-Store = req.http.X-Varnish-Store; } else { unset resp.http.X-Varnish; unset resp.http.Via; unset resp.http.X-Powered-By; unset resp.http.Server; unset resp.http.X-Turpentine-Cache; unset resp.http.X-Turpentine-Esi; unset resp.http.X-Turpentine-Flush-Events; unset resp.http.X-Turpentine-Block; unset resp.http.X-Varnish-Session; unset resp.http.X-Varnish-Host; unset resp.http.X-Varnish-URL; unset resp.http.X-Varnish-Set-Cookie; } }

miguelbalparda commented 7 years ago

No, it's definitely not okey. I think you have an old release with an error I already fixed, a merge conflict. I suggest you to save this elsewhere, download the latest version of the extension and then reapply your changes to avoid future problems.

ivantnt commented 7 years ago

You mean i have to reinstall my Turpentine to the last version available?

Il 28/11/2016 14:37, Miguel Balparda ha scritto:

No, it's definitely not okey. I think you have an old release with an error I already fixed, a merge conflict. I suggest you to save this elsewhere, download the latest version of the extension and then reapply your changes to avoid future problems.

miguelbalparda commented 7 years ago

Yes, the issue I mention is fixed in the latest version. <<<<<<< HEAD and >>>>>>> master should not be there and I find it quite strange it's working actually.

ivantnt commented 7 years ago

I don't know, my provider told me he made some changes, he made some test and me too and apparently the cart now work fine. I copy his reply, anyway the web site i'm testing is http://negozio.benellishop.com . I apreciate very much if you can also try to test

" Hi Ivan,We have deeply checked your issue and adjusted some necessary cookies as well as cache settings and now the cart is working fine without any issue.We have replicated this at our end multiple times and cart functionality is working seamlessly......

"

Anyway now i try to uninstall my version and i try to install it from here https://www.magentocommerce.com/magento-connect/turpentine-varnish-cache.html , right?

Thank you very much for your great support Ivan

Il 28/11/2016 14:44, Miguel Balparda ha scritto:

Yes, the issue I mention is fixed in the latest version. <<<<<<< HEAD and >>>>>>> master should not be there and I find it quite strange it's working actually.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nexcess/magento-turpentine/issues/1319#issuecomment-263274262, or mute the thread https://github.com/notifications/unsubscribe-auth/AVgKMiwrIMjMjCwuqB0EsA-PzFjfWDhIks5rCtqkgaJpZM4K4G1V.

miguelbalparda commented 7 years ago

I'm not entirely sure this was a Turpentine issue since most of the time Varnish support is out of scope for most hosting providers. My best guess is that your hosting provider did some changes somewhere else to make this work. You can get the latest version from there or even from this GitHub repo.

ivantnt commented 7 years ago

Sorry Miguel, you mean that my provider anyway made some changes somewhere that you can't see that solved the problem?....anyway now i try to reinstall the Turpentine to the last version, and if you check my web site give your opinion

Il 28/11/2016 14:55, Miguel Balparda ha scritto:

I'm not entirely sure this was a Turpentine issue since most of the time Varnish support is out of scope for most hosting providers. My best guess is that your hosting provider did some changes somewhere else to make this work. You can get the latest version from there or even from this GitHub repo.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nexcess/magento-turpentine/issues/1319#issuecomment-263276781, or mute the thread https://github.com/notifications/unsubscribe-auth/AVgKMq7aPVWg1rwMp02e-UG9uHGskH7Nks5rCt1VgaJpZM4K4G1V.