Skip to content

Add Cache-Control header to knockout partials #25325

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
merged 2 commits into from
Dec 3, 2019

Conversation

paveq
Copy link
Contributor

@paveq paveq commented Oct 27, 2019

Description (*)

This PR adds Cache-Control headers to knockout partials (.html static content files). Previous PR #8000 failed to add this.

Fixed Issues

Without Cache-Control header in same cases when using caching proxies such as Cloudflare to serve files, end user browser does 304 check each time on every page. This highly depends on proxy configuration, but there should not be any reason not to set Cache-Control header. Is seems with just Expires header set, there's different interpretations what logic should be used for revalidation.

In this PR we set Cache-Control to public, which is same value for all static content files. There is no need for browser to revalidate these requests, as invalidation is handled by static content versioning.

Manual testing scenarios (*)

  1. Open category page
  2. Open browser inspector
  3. Verify that returned response to .html static content file has Cache-Control header
  4. Open another category page
  5. Verify that the same .html file is retrieved from browser disk cache

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • [not applicable] All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@paveq paveq requested a review from akaplya as a code owner October 27, 2019 17:55
@m2-assistant
Copy link

m2-assistant bot commented Oct 27, 2019

Hi @paveq. 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.3-develop instance - deploy vanilla Magento instance

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

@magento-engcom-team magento-engcom-team added Partner: Vaimo Pull Request is created by partner Vaimo partners-contribution Pull Request is created by Magento Partner labels Oct 27, 2019
Copy link
Member

@rodrigowebjump rodrigowebjump left a comment

Choose a reason for hiding this comment

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

Hi @paveq Thanks for your contribution

@magento-engcom-team
Copy link
Contributor

Hi @rodrigowebjump, thank you for the review.
ENGCOM-6189 has been created to process this Pull Request
✳️ @rodrigowebjump, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

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.

Hi @paveq,
Could you also add this change to nginx.conf.sample to make both installations consistent?

@paveq
Copy link
Contributor Author

paveq commented Nov 1, 2019

Hi @paveq,
Could you also add this change to nginx.conf.sample to make both installations consistent?

This is now added.

@magento-engcom-team
Copy link
Contributor

Hi @ihor-sviziev, thank you for the review.
ENGCOM-6189 has been created to process this Pull Request
✳️ @ihor-sviziev, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@ihor-sviziev ihor-sviziev added the Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests label Nov 1, 2019
@engcom-Bravo engcom-Bravo self-assigned this Nov 1, 2019
@engcom-Bravo
Copy link
Contributor

Hello @paveq. Thank You for Your contribution. Could You please help us a bit with Manual Testing and give us some more details on it so that we can be sure we do everything correctly. For example in "Verify that returned response to .html static content file has Cache-Control header" please specify some concrete .html file. Also "Open another category page" means another page of the same category or a page of some other category? Besides do we need to switch to Developer or to Production mode for executing all of that. There also may be some other details will help us to correctly reproduce the scenario. Thank You in advance.

@ihor-sviziev
Copy link
Contributor

@magento give me test instance

@magento-engcom-team
Copy link
Contributor

Hi @ihor-sviziev. Thank you for your request. I'm working on Magento instance for you

@ihor-sviziev
Copy link
Contributor

@magento give me 2.3-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @ihor-sviziev. Thank you for your request. I'm working on Magento 2.3-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @ihor-sviziev, here is your new Magento instance.
Admin access: https://pr-25325.instances.magento-community.engineering/admin
Login: admin Password: 123123q

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Nov 13, 2019

@engcom-Bravo,
Steps to reproduce:

  1. Open Google Chrome developer tools
  2. Navigate to homepage
  3. In Google Chrome dev tools looks at any .js file (I checked on domReady.js file), look at "Response Headers" section

On 2.3-develop:
❌ Cache-Control header is missin
image

On this PR:
✔ Cache-Control header is present
image

In order to make full testing - you need to setup Magento with CDN, for instance CloudFlare or CloudFront and re-check that requests are cached in browser and no requests for .html files were sent to server.

I just tried to test it on test instances and found another issue - #25578.
But anyway that's separate issue that need to be fixed

@engcom-Bravo
Copy link
Contributor

Thank You, @ihor-sviziev. Before proceeding to full testing, can You tell me please if this fix is supposed to be detected on the local environment. Yes, I see it works on the instances You requested above. But I can't see it working on my local instance. In fact Cache-Control header is present only for the main requested recourse, i.e. for example for the testcategory.html if we talk about category page with testcategory url key. Besides it appears only in developer mode and looks differently meaning it contains more information than just "public".

@engcom-Bravo
Copy link
Contributor

✔️ QA Passed

@engcom-Foxtrot engcom-Foxtrot self-assigned this Dec 2, 2019
@VladimirZaets VladimirZaets added Auto-Tests: Covered All changes in Pull Request is covered by auto-tests and removed Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests labels Dec 2, 2019
@magento-engcom-team magento-engcom-team merged commit 8260aa3 into magento:2.3-develop Dec 3, 2019
@m2-assistant
Copy link

m2-assistant bot commented Dec 3, 2019

Hi @paveq, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Partner: Vaimo Pull Request is created by partner Vaimo partners-contribution Pull Request is created by Magento Partner Progress: accept Release Line: 2.3 Squashtoberfest 2019
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants