Skip to content

VCL: Removing max-age directives when using user context hash #232

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

Closed
Closed
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
10 changes: 10 additions & 0 deletions resources/config/varnish-3/fos_user_context.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ sub fos_user_context_deliver {

# If we get here, this is a real response that gets sent to the client.

# Remove cache ttl directives.
# Subsequent Reverse proxies and clients from this point forward cannot Vary
# on user context hash and should not attempt to cache
if (resp.http.X-Cache-Debug) {
# For debug purposes, adds previous ttl to the response headers
set resp.http.X-Original-Cache-Control = resp.http.Cache-Control;
}

set resp.http.Cache-Control = "max-age=0, s-max-age=0, private";

# Remove the vary on context user hash, this is nothing public. Keep all
# other vary headers.
set resp.http.Vary = regsub(resp.http.Vary, "(?i),? *X-User-Context-Hash *", "");
Expand Down
10 changes: 10 additions & 0 deletions resources/config/varnish-4/fos_user_context.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ sub fos_user_context_deliver {

# If we get here, this is a real response that gets sent to the client.

# Remove cache ttl directives.
# Subsequent Reverse proxies and clients from this point forward cannot Vary
# on user context hash and should not attempt to cache
if (resp.http.X-Cache-Debug) {
# For debug purposes, adds previous ttl to the response headers
set resp.http.X-Original-Cache-Control = resp.http.Cache-Control;
}

set resp.http.Cache-Control = "must-revalidate, no-cache, private";

# Remove the vary on context user hash, this is nothing public. Keep all
# other vary headers.
set resp.http.Vary = regsub(resp.http.Vary, "(?i),? *X-User-Context-Hash *", "");
Expand Down