Needs review
Project:
Advanced Varnish
Version:
4.0.9
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
18 Jun 2024 at 15:17 UTC
Updated:
26 Mar 2026 at 09:23 UTC
Jump to comment: Most recent
Comments
Comment #4
shumer commentedСurrent page path can be passed as an additional query parameter in the ESI URL. The ESIBlockController would then read it and set up the route context accordingly.
However, this must not be the default behavior. Adding the page path to every ESI URL means Varnish caches the same block separately for every page, defeating the purpose of ESI for blocks that don't depend on page context (menus, sidebars, user blocks, etc.).
We can make a slightly diff approach:
1. Add a "Context-aware" checkbox to the ESI block configuration (next to the existing ESI/cachemode/TTL settings)
2. When enabled, _adv_varnish_build_esi_block() passes the current path as a query parameter (e.g. &context_path=/node/42)
3. ESIBlockController::content() reads context_path, resolves the route, and pushes it onto the route match so block plugins see the correct context
4. No VCL changes needed, Varnish already caches by full URL including query string
This keeps cache efficiency for context-independent blocks while enabling page-aware ESI for blocks that need it
Comment #5
shumer commentedComment #6
shumer commentedCode style issues fixed, testing coverage added. PR ready for review/validation.