Skip to content

Conversation

@rrennick
Copy link
Contributor

@rrennick rrennick commented Jun 17, 2020

All Submissions:

Changes proposed in this Pull Request:

This PR adds a woocommerce_enable_nocache_headers filter to allow CDN plugins to disable adding the WC nocache headers.

Closes # .

How to test the changes in this Pull Request:

  1. Open the network tab in your browser console.
  2. Navigate to the shop page.
  3. Check the headers for cache-control: no-transform, no-cache, no-store, must-revalidate
  4. Add the filter add_filter( 'woocommerce_enable_nocache_headers', '__return_false' );
  5. Reload the page
  6. Check the headers for cache-control: no-cache, no-store, must-revalidate

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?

Changelog entry

Dev - Add filter to allow disabling nocache headers.

@rrennick rrennick added Enhancement The issue is a request for an enhancement. status: needs review labels Jun 17, 2020
@lkraav
Copy link
Contributor

lkraav commented Jun 18, 2020

It still doesn't explain why there's a misleading core comment

// no-transform: Opt-out of Google weblight if page is dynamic e.g. cart/checkout. https://support.google.com/webmasters/answer/6211428?hl=en.

But there's no actual if code branch, and it's applied sitewide.

@rrennick
Copy link
Contributor Author

It still doesn't explain why there's a misleading core comment

@lkraav Thanks, nice catch.

@rrennick
Copy link
Contributor Author

But there's no actual if code branch, and it's applied sitewide.

The nocache_headers filter runs before WP_Query has parsed the query. To make this conditional we would need to duplicate the WP_Query logic. If the WP core filter was moved to after the query was parsed that would make conditional logic more practical. I searched recent core track and didn't see a request for that.

Copy link
Contributor

@claudiosanches claudiosanches left a comment

Choose a reason for hiding this comment

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

LGTM!

@woocommercebot woocommercebot added status: approved and removed Enhancement The issue is a request for an enhancement. status: needs review labels Jun 23, 2020
@rrennick rrennick merged commit e9f71ac into master Jun 23, 2020
@rrennick rrennick deleted the fix/25833 branch June 23, 2020 16:35
@woocommercebot woocommercebot added release: add changelog Mark all PRs that have not had their changelog entries added. [auto] release: add testing instructions PRs that have not had testing instructions added to the wiki. [auto] labels Jun 23, 2020
@Konamiman Konamiman added this to the 4.4.0 milestone Jul 27, 2020
@tammullen tammullen removed the release: add testing instructions PRs that have not had testing instructions added to the wiki. [auto] label Jul 28, 2020
@Konamiman Konamiman removed the release: add changelog Mark all PRs that have not had their changelog entries added. [auto] label Jul 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants