Skip to content

Instantly share code, notes, and snippets.

@hostep
hostep / magento-varnish-esi-include-problem.md
Last active January 20, 2026 10:46
Magento Varnish caching problem with `esi:include` tags sometimes being outputted in html on url's that contain `/customer`

This discusses an issue in Magento when Varnish is active, that on certain pages (mostly containing /customer in the url) you'll see the top navigation missing and an esi:include tag being included in the html. This is related to Varnish not understanding certain compression algorithms, like Brotli.

Note, we're only talking about GET requests here, not about POST requests.

  1. Magento has a way to say if a page is cacheable or not. A page is cacheable by default, unless it mentions cacheable="false" in one of its blocks, in its layout xml file.
  2. Based on if a page is cacheable or not, Magento will send different caching HTTP headers back
  3. Just for information, following pages are considered cacheable (unless the old skool captcha module is active, which makes most of these uncacheable):
    • customer/account/confirmation
    • customer/account/create
  • customer/account/forgotpassword
@hostep
hostep / composer-v2-support-older-magento2-versions.md
Last active July 2, 2025 00:06
Add composer v2 support to older Magento2 versions

Add composer v2 support to older Magento2 versions

Magento 2.3.7 and 2.4.2 ship with composer v2 support out of the box but as far as I can see the only thing that needs to happen is to use some more modern versions of certain composer plugins which are used by certain dependencies of Magento.

This means we should be able to add composer v2 support to older Magento2 versions as well if we get a bit creative.

See below for diffs of the composer.json files you can apply to your projects, be sure to keep a mental note of these things, they will need to maintained by yourself in case newer versions of these modules are released. And if one day you update to Magento 2.3.7 or 2.4.2 or higher, you can remove these changes again.

⚠️ Disclaimer: use these tricks at your own risk!

<?php
// The idea here is:
// - install Magento 2.3.3 and 2.3.3-p1 using composer in two different directories
// - loop over all directories in vendor/magento of those two installations
// - generate diff using 'git diff --no-index'
// - search and replace file paths in the diff and write it back as is
// - also output composer.patches.json file which can be used with the cweagans/composer-patches package
declare(strict_types=1);