Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all marketing get parameters to minimize the cache #39099

Open
wants to merge 7 commits into
base: 2.4-develop
Choose a base branch
from

Conversation

rogerdz
Copy link
Contributor

@rogerdz rogerdz commented Aug 23, 2024

Description (*)

Same logic when use varnish (https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/PageCache/etc/varnish7.vcl#L84) but for build-in fpc

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes magento/magento2#<issue_number>

Manual testing scenarios (*)

  1. Clear cache: bin/magento cache:clean
  2. Run command: curl -I --location-trusted 'https://magento2.test/gear/bags.html?test=111&utm_source=123&gclid=abc' | grep -i X-Magento-Cache-Debug, it return x-magento-cache-debug: MISS => correct
  3. Run command: curl -I --location-trusted 'https://magento2.test/gear/bags.html?test=111&utm_source=123&gclid=abc' | grep -i X-Magento-Cache-Debug, it return x-magento-cache-debug: HIT => correct
  4. Run command: curl -I --location-trusted 'https://magento2.test/gear/bags.html?test=111' | grep -i X-Magento-Cache-Debug => it should return x-magento-cache-debug: HIT

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. resolves [Issue] Remove all marketing get parameters to minimize the cache #39266: Remove all marketing get parameters to minimize the cache

Copy link

m2-assistant bot commented Aug 23, 2024

Hi @rogerdz. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.

Add the comment under your pull request to deploy test or vanilla Magento instance:
  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ 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
ℹ️ 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.

@rogerdz
Copy link
Contributor Author

rogerdz commented Aug 23, 2024

@magento run all tests

@rogerdz
Copy link
Contributor Author

rogerdz commented Aug 23, 2024

@magento run all tests

@engcom-Hotel engcom-Hotel added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Aug 27, 2024
@sprankhub
Copy link
Member

Nice. Maybe you want to update the parameters based on https://github.com/magento/magento2/pull/39188/files#diff-40e00b332f8dd95fbf48a312b9b8cfeee0d4e70bd7528c0e794c84c9e00c113fR85.

@Priyakshic Priyakshic added the Project: Community Picked PRs upvoted by the community label Oct 15, 2024
@engcom-Hotel engcom-Hotel self-requested a review October 16, 2024 06:43
@engcom-Hotel
Copy link
Contributor

@magento create issue

@engcom-Hotel
Copy link
Contributor

@magento run all tests

@engcom-Hotel
Copy link
Contributor

@magento run Database Compare, Functional Tests B2B, Functional Tests CE

@sprankhub
Copy link
Member

Please mind that #39188 is also community-picked and is more complete. Specifically, it includes the changes from this PR. Hence, I think the solution from #39188 should be merged.

@hostep
Copy link
Contributor

hostep commented Oct 16, 2024

@sprankhub, I think you got confused and meant to comment on #35228
This PR here adds the extra parameters to the non-Varnish based FPC solution from Magento. But I believe the list should be updated with the list from #39188 so they match 100%.

Ideally we should have one place where the entire list is defined and can be used both by the Varnish VCL file generator and the non-Varnish based FPC solution. Maybe using a backoffice configuration field? We have a new request for that since today BTW: #39268 (even though the example given there is a very bad idea)

Copy link
Contributor

@ihor-sviziev ihor-sviziev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I got right, you’re removing cache parameters on Magento (php) side.
for that purpose, Varnish does way better job, since it works way better and uses resources more efficiently.
I don’t see how someone would use built in full page cache in production, so I don’t think we should update it

Example use case:
you added a new service, let’s say Klaviyo, that adds a dynamic value for each client.
Marketing team has sent an email to all subscribers and they starting clicking on link that goes to a single product page.
What we have right now is - the dynamic get parameter will be removed by Varnish, and after the first request - it will put the result in cache. all next requests will not get to Magento/php - so they will be delivered to clients waaaay faster and won’t create load to web servers, database and redis.
if we accept your changes - this would mean that this dynamic get parameter will be removed on php side, which will result in additional slower responses, additional load to web servers, database and redis.

Having all that in mind, I don’t think we can accept this pull request, but instead, we should actualize the list in Varnish config.

Please correct me if I’m wrong

@ihor-sviziev
Copy link
Contributor

Sorry, looks like I got confused a bit.
But still, it’s not clear if it worth fixing built in full page cache. Does anyone using it in production? If no - why would we support the list in 2 places?

@hostep
Copy link
Contributor

hostep commented Oct 17, 2024

Yes, people use Magento shops without Varnish in production as Varnish requires a big amount of memory and certain shops have soo little traffic it's not worth paying the extra cash for extra resources. In that case the built-in FPC using filesystem as storage is more then adequate enough. Some of our clients use this sort of setup.

Copy link
Contributor

@ihor-sviziev ihor-sviziev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please cover your changes with unit tests?

@rogerdz
Copy link
Contributor Author

rogerdz commented Oct 28, 2024

@magento run all tests

@rogerdz
Copy link
Contributor Author

rogerdz commented Oct 28, 2024

Could you please cover your changes with unit tests?

I updated unit test + marketing parameters

* Pattern detect marketing parameters
*/
public const PATTERN_MARKETING_PARAMETERS = [
'/&?gad_source\=[^&]+/',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to extract this list to method that can be later pluginized. Or use dedicated class where those patterns can be injected via DI. Or even better to allow editing this list via admin panel.

If merchant uses some local marketing tools that are not part of this list then - hardcoded public const PATTERN_MARKETING_PARAMETERS cannot be easily overridden to remove custom tracking params.

As someone in CR suggested this service can also be used to generate Varnish config.

@@ -38,9 +48,11 @@ public function __construct(
*/
public function getValue()
{
$pattern = Identifier::PATTERN_MARKETING_PARAMETERS;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is not extendable to append custom patterns. Dedicated service or public method visible to plugins would work better.

* property laws, including trade secret and copyright laws.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained from
* Adobe.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This copyright header is too big.
Also the year should be the year the file was created, not when it was last updated.

So in this case the copyright header should be:

 * Copyright 2023 Adobe
 * All Rights Reserved.

Nothing else is needed. Not sure where you got that other paragraph from?

Same remark goes for the other files.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to be moved to separate file COPYING.txt or LICENSE.txt for better opportunity for update the policies.

It's takes years to remove @author tag (comments block) from files, what will happens if all files requires updated license ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not use any year dates, just use the default magento header here:

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

Copy link
Contributor Author

@rogerdz rogerdz Oct 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new rule from magento coding standard (https://github.com/magento/magento-coding-standard/blob/develop/Magento2Framework/Sniffs/Header/CopyrightValidation.php)
I'm copy from core
Have 94 file same format
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It couldn't have been made any longer lol but thanks, I hadn't thought of that either

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: review Project: Community Picked PRs upvoted by the community
Projects
Status: Changes Requested
Development

Successfully merging this pull request may close these issues.

[Issue] Remove all marketing get parameters to minimize the cache
9 participants