magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Duplicate cache fpc for same page with same query when use varnish

Open rogerdz opened this issue 10 months ago • 10 comments

Description (*)

Same as https://github.com/magento/magento2/issues/38269 but for varnish Inspire by: https://varnish-cache.org/docs/trunk/reference/vmod_std.html#string-querysort-string

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes magento/magento2#<issue_number>

Manual testing scenarios (*)

  1. Setup magento with varnish
  2. Clear cache: bin/magento cache:clean
  3. Run command: curl -I --location-trusted 'https://magento2.test/gear/bags.html?activity=8&style_bags=24' | grep -i X-Magento-Cache-Debug, it will return x-magento-cache-debug: MISS => correct
  4. Run command: curl -I --location-trusted 'https://magento2.test/gear/bags.html?activity=8&style_bags=24' | grep -i X-Magento-Cache-Debug, it will return x-magento-cache-debug: HIT => correct
  5. Run command: curl -I --location-trusted 'https://magento2.test/gear/bags.html?style_bags=24&activity=8' | grep -i X-Magento-Cache-Debug => it return x-magento-cache-debug: MISS => wrong
  6. Run command: curl -I --location-trusted 'https://magento2.test/gear/bags.html?activity=8&style_bags=24&' | grep -i X-Magento-Cache-Debug => it return x-magento-cache-debug: MISS => wrong

Questions or comments

Contribution checklist (*)

  • [ ] Pull request has a meaningful description of its purpose
  • [ ] All commits are accompanied by meaningful commit messages
  • [ ] All new or changed code is covered with unit/integration tests (if applicable)
  • [ ] README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • [ ] All automated tests passed successfully (all builds are green)

Resolved issues:

  1. [x] resolves magento/magento2#39706: Duplicate cache fpc for same page with same query when use varnish

rogerdz avatar Mar 05 '25 04:03 rogerdz

Hi @rogerdz. Thank you for your contribution! Here are some useful tips on how you can test your changes using Magento test environment. :exclamation: Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s) For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here :information_source: Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation. Join Magento Community Engineering Slack and ask your questions in #github channel.

m2-assistant[bot] avatar Mar 05 '25 04:03 m2-assistant[bot]

@magento run all tests

rogerdz avatar Mar 05 '25 04:03 rogerdz

Nice, this is also being suggested in https://gist.github.com/peterjaap/006169c5d95eeffde3a1cc062de1b514?permalink_comment_id=5197461#gistcomment-5197461

Looks good to me!

hostep avatar Mar 05 '25 10:03 hostep

@magento create issue

engcom-Hotel avatar Mar 05 '25 13:03 engcom-Hotel

Micro-optimization; add an if check to avoid re-setting the URL (and causing load and logging) when there are not multiple parameters;

if (req.url ~ "\?.+&.+") {
    set req.url = std.querysort(req.url);
}

peterjaap avatar May 22 '25 14:05 peterjaap

@magento run all tests

rogerdz avatar May 26 '25 02:05 rogerdz

@magento run all tests

engcom-Hotel avatar Dec 09 '25 06:12 engcom-Hotel

@magento run Integration Tests, Unit Tests

engcom-Hotel avatar Dec 09 '25 10:12 engcom-Hotel

@magento run all tests

engcom-Dash avatar Dec 10 '25 13:12 engcom-Dash

@magento run all tests

engcom-Dash avatar Dec 11 '25 18:12 engcom-Dash

Hello @rogerdz ,

Thanks for the contribution!

✔️ QA Passed

Preconditions: Install fresh Magento 2.4-develop

Manual testing scenarios

  1. Setup magento with Varnish
  2. Clear cache: bin/magento cache:clean

Before image

After image

Builds are failing. Hence, moving this PR to Extended Testing.

engcom-Dash avatar Dec 15 '25 09:12 engcom-Dash

@magento run all tests

engcom-Dash avatar Dec 15 '25 10:12 engcom-Dash

@magento run all tests

engcom-Dash avatar Dec 16 '25 08:12 engcom-Dash

The consistent failures in Functional B2B are known issues and JIRA is open for the same. The other failures are inconsistent and flaky. They neither part of the PR nor failing because of the PR changes.

B2B Build 1 https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/39704/0400144841c670f66d1bac1284fd1da0/Functional/allure-report-b2b/index.html#categories/9885042fbe0ad1ecbbd322a9e71e03a5/3c1c4bb151c3f754/ image

Build 2 https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/39704/ba5d26f93056a629dc45058b9749e210/Functional/allure-report-b2b/index.html#categories/9885042fbe0ad1ecbbd322a9e71e03a5/eed6555510567ff5/ image

KnownIssue: AdminUpdateProductQuantityInNegotiableQuoteTestACQE-8869

Hence, Moving this PR for Merge In Progress

engcom-Dash avatar Dec 16 '25 11:12 engcom-Dash