Skip to content

Allow to cache search results #30340

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

Merged

Conversation

alinalexandru
Copy link
Member

@alinalexandru alinalexandru commented Oct 5, 2020

Description (*)

Starting version 2.2.4, search result page can be cached, but varnish vcl has a rule to not cache the page.

Manual testing scenarios (*)

  1. Configure magento to use varnish for FPC
  2. Do a search with one of the top 100 searches (default value), or go to Go to Admin -> Stores -> Configuration -> Catalog -> Catalog -> Catalog Search and set Number of top search results to cache to 0 (this will set to cache all the results)
  3. Do the same query, to see if you hit the cache.

Actual result:

  • The search page is not cached.

Expected result:

  • The search page should be delivered from cache

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)
  • All automated tests passed successfully (all builds are green)

Resolved issues:

  1. resolves [Issue] Allow to cache search results #30508: Allow to cache search results

@m2-assistant
Copy link

m2-assistant bot commented Oct 5, 2020

Hi @alinalexandru. Thank you for your contribution
Here is some useful tips 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

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

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

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests 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.

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

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

@sidolov sidolov added Priority: P3 May be fixed according to the position in the backlog. Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. labels Oct 5, 2020
Copy link
Contributor

@rogyar rogyar left a comment

Choose a reason for hiding this comment

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

Hi @alinalexandru. Thank you for your collaboration. From my point of view, we cannot allow all /catalogsearch pages to be cached by Varnish since this behavior goes against the idea of "Cacheable Search Terms". If we allow caching 100 popular items it applies only to the limited amount of pages.

$this->getCacheableResult($catalogSearchHelper, $query, $handles);

If we allow Varnish to cache /catalogsearch URLs, it may affect not only "popular" search terms but all search pages. Considering the fact that we may have an infinite number of different catalog search queries in the URL, it may be a good way to overflow the Varnish storage.

Please, correct me if I'm wrong.

@alinalexandru
Copy link
Member Author

@rogyar
Removing this line tells Varnish that it can cache the page if Magento allows it by sending corresponding headers.
If that condition is there, Varnish will not cache that page, no matter what Magento tells Varnish to do.

Magento will be in charge to decide if that page can be cached or not. In the current implementation, the search result page can be cached only if it's a popular search and it doesn't have any other get parameters.

You can see what happens if the page should not be cached:

@alinalexandru
Copy link
Member Author

@rogyar
What's your feedback regarding what I have wrote?
Is there something that I am missing?

@rogyar rogyar added the Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests label Oct 12, 2020
@rogyar
Copy link
Contributor

rogyar commented Oct 12, 2020

Hi @alinalexandru. Not it totally makes sense. Thanks a lot for the explanation and examples.

@rogyar
Copy link
Contributor

rogyar commented Oct 12, 2020

@magento run all tests

@magento-engcom-team
Copy link
Contributor

Hi @rogyar, thank you for the review.
ENGCOM-8329 has been created to process this Pull Request

@magento-engcom-team
Copy link
Contributor

@alinalexandru thank you for contributing. Please accept Community Contributors team invitation here to gain extended permissions for this repository.

@engcom-Alfa
Copy link
Contributor

@magento create issue

@engcom-Alfa
Copy link
Contributor

✔️ QA Passed

Case 1

Manual testing scenario:

  1. Configure magento to use varnish for FPC
  2. Do a search with one of the top 100 searches (default value), or set Number of top search results to cache to 0 (this will set to cache all the results)
  3. Do the same query, to see if you hit the cache.

Before: ✖️ The search page is not cached.

Peek 2020-10-16 10-22

After: ✔️ The search page was delivered from the cache

2020-10-16_09-44

Peek 2020-10-16 10-20

Case 2

Manual testing scenario:

  1. Configure magento to use varnish for FPC
  2. Go to Admin -> Stores -> Configuration -> Catalog -> Catalog -> Catalog Search and ser Number of top search results to cache to 2 (this will set to cache 2 terms)
  3. Do the same query, to see if you hit the cache.

After: ✔️ Only 2 search queries were cached, all subsequent queries are not

@engcom-Alfa engcom-Alfa added the QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope label Oct 16, 2020
@m2-assistant
Copy link

m2-assistant bot commented Oct 21, 2020

Hi @alinalexandru, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

kandy added a commit to kandy/fastly-magento2 that referenced this pull request Oct 21, 2020
@alinalexandru alinalexandru deleted the varnish-search-page branch December 2, 2020 15:09
MickaelDatadome pushed a commit to DataDome/fastly-magento2 that referenced this pull request Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests Award: bug fix Component: PageCache Priority: P3 May be fixed according to the position in the backlog. Progress: accept QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope Release Line: 2.4 Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[Issue] Allow to cache search results
5 participants