Automattic / woocommerce-payments

Accept payments via credit card. Manage transactions within WordPress.
https://wordpress.org/plugins/woocommerce-payments/
Other
173 stars 69 forks source link

Site Health Reports Performance errors related to wcpay_currency cookie #8679

Closed darcie closed 5 months ago

darcie commented 6 months ago

Describe the bug

Related to #8534

After updating to WooPayments 7.5.1, Site Health sometimes reports a critical performance issue.

Page cache is not detected and the server response time is slow

Page cache enhances the speed and performance of your site by saving and serving static pages instead of calling for a page every time a user visits.

Page cache is detected by looking for an active page cache plugin as well as making three requests to the homepage and looking for one or more of the following HTTP client caching response headers:

cache-control, expires, age, last-modified, etag, x-cache-enabled, x-cache-disabled, x-srcache-store-status, x-srcache-fetch-status.
 Median server response time was 1,419 milliseconds. It should be less than the recommended 600 milliseconds threshold.
 No client caching response headers were detected.
 A page cache plugin was not detected.
[Learn more about page cache(opens in a new tab)](https://wordpress.org/documentation/article/optimization/#Caching)

Upon checking in hosting, it appeared to be related to this string:

set-cookie: wcpay_currency=GBP_1; expires=Fri, 19-Apr-2024 11:05:09 GMT; Max-Age=3600; path=/

To Reproduce

  1. Have WooPayments 7.5.1 installed with multicurrency enabled
  2. Go to Tools > Site Health
  3. See the error once Site Health completes loading

Actual behavior

The error seems to be temporary in some cases, I reproduced it with Multi-currency enabled but no additional currencies as well as multiple added currencies.
The merchant did not notice any change in site behavior yet, but was concerned about the critical warning.

Screenshots

Screenshot 2024-04-19 at 5 01 03 PM

Expected behavior

No performance change with the additions of #8645

Additional context

8070554-zd-a8c

bborman22 commented 6 months ago

I've updated the focus label and linked PR. This is an issue with the wcpay_currency cookie and how it is being set. We'll be exploring ways to address this in the next release.

bborman22 commented 6 months ago

@rafaelzaleski Given the note about the set cookie header preventing caching, is there a different approach we could take here? My thoughts are not setting it when the same or setting through another mechanism (I'm less clear on this as I know there was some effort around HTTP only cookies or not).

bborman22 commented 6 months ago

Please add your planning poker estimate with Zenhub @rafaelzaleski

bborman22 commented 5 months ago

We'll be reverting the cookie change that causes this caching issue in WooPayments 7.6.0 releasing on May 8 and will reopen the https://github.com/Automattic/woocommerce-payments/issues/8130 as we look for a better solution.