You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Magento扩展发布遇Varnish缓存问题:审核因HIT头部缺失被拒

Troubleshooting Varnish HIT Header Issue for Magento Extension Marketplace Submission

Hey there, let's work through this frustrating Varnish cache issue you're hitting with your Magento extension submission. I know how tricky Marketplace validation can be, especially when you've already followed existing guides but still get rejected. Here are some targeted steps to fix the "no HIT in page cache headers" problem:

  • Double-check your Varnish TTL and Cache-Control headers
    Even if all blocks are marked cacheable="true", Varnish might not cache the page if the TTL is too short or Magento is sending conflicting Cache-Control directives. Run curl -I https://your-test-store-url and look for:

    • X-Varnish: If this has two request IDs (e.g., 12345 67890), that means it was a MISS. A single ID means HIT.
    • Cache-Control: Make sure it doesn't include no-cache, no-store, or max-age=0—these will prevent Varnish from caching the page.
    • Age: A value greater than 0 confirms the response came from Varnish's cache.
  • Ensure your entire page is fully cacheable
    Magento's full-page cache is all-or-nothing: one non-cacheable block breaks the whole page's cache. You said you set cacheable="true" on all blocks, but dig deeper:

    • Check nested blocks in your layout XML—child blocks might inherit non-cacheable settings from parent blocks you missed.
    • Use Magento's built-in debug tool: Go to System > Cache Management > Page Cache Debug (enable it first), then visit your page. It will highlight any elements that are preventing caching (like dynamic customer-specific content).
  • Audit Varnish's pass rules
    Your Varnish config might be skipping cache for certain requests. Common culprits include:

    • Unnecessary cookies set by your extension: If your extension adds cookies for anonymous users, Varnish might treat the request as uncacheable. Clear all cookies and test again.
    • Overly restrictive VCL rules: Make sure your Varnish config isn't passing requests with standard Magento cookies (like PHPSESSID for anonymous sessions) or specific URL patterns used by your extension.
  • Test as an anonymous user
    Marketplace reviewers test as anonymous visitors—if you're testing while logged into the Magento admin or customer account, the page won't be cached. Always use an incognito window, clear your browser cache/cookies, and test again.

  • Handle dynamic content with ESI
    If your extension has dynamic content (like personalized data), marking blocks as cacheable="true" isn't enough. You need to use Edge Side Includes (ESI) to let Varnish cache the static parts of the page while fetching dynamic content separately. Add xhtml:include="true" to your block's layout XML, like this:

    <block class="Vendor\Extension\Block\Dynamic" name="dynamic.block" cacheable="true" xhtml:include="true" />
    

    This tells Varnish to split the block into a separate ESI request, which can be cached independently.

  • Dig into Varnish logs for clues
    Use the varnishlog command to see exactly what's happening with your requests. Run this in your server terminal:

    varnishlog -g request -q "ReqUrl ~ '/path-to-your-extension-page'"
    

    Look for lines like Hit or Miss in the logs, and check the VCL_* stages to see if any rules are causing Varnish to skip caching your page.

After working through these steps, retest your page and verify the headers have a clear HIT. The main goal is to make sure the entire page is cacheable, Varnish is configured to store it, and any dynamic content is properly handled with ESI.

内容的提问来源于stack exchange,提问作者Ruslan Barlozhetskyi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:37:10