Skip to content

IBX-12244: Restored refresh-instead-of-stale for logged-in users on Varnish 7 - #86

Open
vidarl wants to merge 1 commit into
IBX-12241-varnish-cache-behatfrom
IBX-12244-varnish7-vcl-hit
Open

IBX-12244: Restored refresh-instead-of-stale for logged-in users on Varnish 7#86
vidarl wants to merge 1 commit into
IBX-12241-varnish-cache-behatfrom
IBX-12244-varnish7-vcl-hit

Conversation

@vidarl

@vidarl vidarl commented Aug 12, 2026

Copy link
Copy Markdown
Contributor
🎫 Issue IBX-12244

Caution

This PR Depends on #85 so base branch is set to IBX-12241-varnish-cache-behat. However, do not merge into IBX-12241-varnish-cache-behat. Instead it should be merged into 46 once #85 has been merged there.

Description:

varnish5.vcl and varnish6.vcl calls return (miss) from vcl_hit to prevent logged-in users
from receiving stale content. Calling return (miss) from vcl_hit is not supported in varnish7
and later. And the functionality was never ported to the varnish7 vcl.
This caps the grace period per request in vcl_recv instead, right after cookie normalisation so
only surviving session cookies count:

if (req.http.cookie && std.healthy(req.backend_hint)) {
    set req.grace = 0s;
}

For QA:

FYI : Due to #85, there is now a behat test for this specific case:

Scenario: A logged-in user in the grace window gets a refreshed response, not a stale one

Documentation:

@sonarqubecloud

Copy link
Copy Markdown

Comment on lines +65 to +66
// window. varnish5/6.vcl do this in vcl_hit with return (miss), which later versions do not support.
if (req.http.cookie && std.healthy(req.backend_hint)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isn't req.http.cookie too broad? Wouldn't it make more sense to narrow it down to req.http.Cookie ~ "eZSESSID" or similar? I would say every user carries some cookie even if not logged or am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants