Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use X-Requested-With header in hash so that xhr and standard requests… #1341

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/code/community/Nexcessnet/Turpentine/misc/version-2.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,14 @@ sub vcl_hash {
set req.hash += regsub(req.http.Cookie, "^.*?customer_group=([^;]*);*.*$", "\1");
}

# Some extension controllers serve different results for a single url depending on
# whether the request is xhr. prototype and jquery both set X-Requested-With
# headers on ajax requests, we can use them in the hash so that both variations
# are served seperately
if (req.http.X-Requested-With) {
set req.hash += req.http.X-Requested-With
}

return (hash);
}

Expand Down
11 changes: 10 additions & 1 deletion app/code/community/Nexcessnet/Turpentine/misc/version-3.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,16 @@ sub vcl_hash {
req.http.Cookie ~ "customer_group=") {
hash_data(regsub(req.http.Cookie, "^.*?customer_group=([^;]*);*.*$", "\1"));
}


# Some extension controllers serve different results for a single url depending on
# whether the request is xhr. prototype and jquery both set X-Requested-With
# headers on ajax requests, we can use them in the hash so that both variations
# are served seperately
if (req.http.X-Requested-With) {
std.log("hash_data xhr request - X-Requested-With: " + req.http.X-Requested-With);
hash_data(req.http.X-Requested-With);
}

return (hash);
}

Expand Down
10 changes: 10 additions & 0 deletions app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,16 @@ sub vcl_hash {
req.http.Cookie ~ "customer_group=") {
hash_data(regsub(req.http.Cookie, "^.*?customer_group=([^;]*);*.*$", "\1"));
}

# Some extension controllers serve different results for a single url if the
# request is xhr. both prototype and jquery set X-Requested-With headers
# on ajax requests so we can add that to the hash so that both variations
# are served seperately
if (req.http.X-Requested-With) {
std.log("hash_data xhr request - X-Requested-With: " + req.http.X-Requested-With);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should leave this here? Maybe wrap it with a debug condition might be better,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I am not 100% understanding what you are referring too. Just the log or the whole condition?

For the log I was just kind of following the format used in the rest of the vcl. Happy to wrap it in some kind of debug condition but might need some instruction on what you need exactly.

I could also wrap the whole thing in a condition controlled by an admin setting similar to some of the other features. That way we can turn the whole thing on/off. I guess it kind of depends if the new hash will affect other installs in any way.

hash_data(req.http.X-Requested-With);
}

std.log("vcl_hash end return lookup");
return (lookup);
}
Expand Down