magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.44k stars 9.29k forks source link

_isScopePrivate vs ESI hole punching vs private data #33555

Closed onlinebizsoft closed 2 years ago

onlinebizsoft commented 3 years ago

Summary (*)

Related to https://github.com/magento/magento2/pull/31754 https://support.magento.com/hc/en-us/articles/360040208612--isScopePrivate-in-private-content-blocks-slows-Magento-performance https://devdocs.magento.com/guides/v2.3/extension-dev-guide/cache/page-caching/private-content.html

_isScopePrivate couldn't be replaced by "private content" completely

Examples (*)

When you have a small block for announcement which appears on every page of the website, it has no interaction with user action (different from users action like adding to cart,....). The block may have content changed often but you wont want to flush whole cache to get it updated to every user. In this case you really want to use _isScopePrivate or ESI hole punching (depends on developer choice). It can't be done or replaced by "private content"

Proposed solution

So I don't understand why you are going to remove _isScopePrivate in future? We should keep the feature as it is and you just need to change to "private content" for necessary user cases.


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

m2-assistant[bot] commented 3 years ago

Hi @onlinebizsoft. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

:movie_camera: You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

onlinebizsoft commented 3 years ago

@mrtuvn @sivaschenko @ihor-sviziev

mrtuvn commented 3 years ago

Actually it's only note deprecated and nothing removed in code base. You still can use private scope variable. But i think we should update docs content for clarify lack of information new cache approach. New approach for private content is like product compare functional (section ajax update) https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Catalog/etc/frontend/sections.xml#L11 Some other cases we can set cache_lifetime (via xml or php block) to false for dynamic block content https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Swatches/view/frontend/layout/wishlist_index_configure_type_configurable.xml#L18 Or wrap Esi (varnish) with ttl define https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Theme/view/frontend/layout/default.xml#L76 cc: @Vinai Maybe he will have more details on this area Current magento still used old way (scopePrivate) in some other places example Checkout Blocks New functional while developments i rarely use scopePrivate and definitely avoid cacheables false in some cases

onlinebizsoft commented 3 years ago

@mrtuvn you refer to product compare but it is not same, it could be done with "private data" because an user action "add to compare" can trigger an invalidation,.... However the private scope variable is helpful when we want a small non-cacheable block on all pages

Vinai commented 3 years ago

The main benefit from my point of view is that private scope blocks make migrating blocks from Magento 1 to Magento 2 very easy. It would be cool if the deprecation note from the docs would be removed.

m2-assistant[bot] commented 2 years ago

Hi @engcom-Delta. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Delta commented 2 years ago

Hi @mrtuvn ,

Thank you for raising an issue , we are happy to work on this issue . Kindly provide steps to reproduce , actual results with screenshots.

Regards,

engcom-Delta commented 2 years ago

We have noticed that this issue has not been updated for a period of more than 14 Days. Hence we assume that this issue is fixed now, so we are closing it. Please raise a fresh ticket or reopen this ticket if you need more assistance on this.

Vinai commented 2 years ago

lol

engcom-Hotel commented 2 years ago

We are reopening this issue for further analysis.

m2-assistant[bot] commented 2 years ago

Hi @engcom-Lima. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Lima commented 2 years ago

HI @onlinebizsoft,

I have gone through the conversation happened on this issue and did some research on same.

Based on it, I think the decision to discourage the use of _isScopePrivate() is related to performance and main purpose was ‘Reduce AJAX requests due to non-cacheable blocks’ as suggested in the below article:

https://developer.adobe.com/commerce/php/development/cache/page/private-content/

And for the example which you have provided, I agree for the use case which you mentioned, _isScopePrivate() can be seen as work approach but that’s why it is recommended to handle it on the web browser or client side instead of sending multiple requests to server. Since _isScopePrivate() can trigger additional AJAX requests, that is why it is discouraged from Magento’s performance perspective.

Hope the above explanation is helpful. If you still have any doubt, feel free to comment back or let us know if we can close this issue ?

Thanks

engcom-Lima commented 2 years ago

Hi @onlinebizsoft ,

We have noticed that this issue has not been updated for a period of 14 Days. Hence we assume that this issue is fixed now, so we are closing it.Please raise a fresh ticket or reopen this ticket if you need more assistance on this.

Thanks