Duplicate cache fpc for same page with same query when use varnish
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)
- Fixes magento/magento2#<issue_number>
Manual testing scenarios (*)
- Setup magento with varnish
- Clear cache: bin/magento cache:clean
- 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
- 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
- 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
- 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:
- [x] resolves magento/magento2#39706: Duplicate cache fpc for same page with same query when use varnish
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:
-
Database Compare -
Functional Tests CE -
Functional Tests EE -
Functional Tests B2B -
Integration Tests -
Magento Health Index -
Sample Data Tests CE -
Sample Data Tests EE -
Sample Data Tests B2B -
Static Tests -
Unit Tests -
WebAPI Tests -
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.
@magento run all tests
Nice, this is also being suggested in https://gist.github.com/peterjaap/006169c5d95eeffde3a1cc062de1b514?permalink_comment_id=5197461#gistcomment-5197461
Looks good to me!
@magento create issue
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);
}
@magento run all tests
@magento run all tests
@magento run Integration Tests, Unit Tests
@magento run all tests
@magento run all tests
Hello @rogerdz ,
Thanks for the contribution!
✔️ QA Passed
Preconditions: Install fresh Magento 2.4-develop
Manual testing scenarios
- Setup magento with Varnish
- Clear cache: bin/magento cache:clean
Before
After
Builds are failing. Hence, moving this PR to Extended Testing.
@magento run all tests
@magento run all tests
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/
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/
KnownIssue: AdminUpdateProductQuantityInNegotiableQuoteTestACQE-8869
Hence, Moving this PR for Merge In Progress