Closed midweste closed 2 years ago
An added bonus imo, is that the hooks still run so that will allow users to determine if a url should be added or not. Added in array_unique to remove any duplicates added by user hooks
@jacobbednarz And by all means, keep commenting and offering direction. I'm far more interested in code that is robust vs quickly published.
other than the small naming change, i think we're good here. thanks for the contribution!
other than the small naming change, i think we're good here. thanks for the contribution!
Thanks for helping me through it!
I have a use case that would have required many extraneous requests to clear related urls from the cache.
Use case: Woocommerce coupon is updated. Products that are valid for this coupon and their related links need to be cleared from cache.
Problem: Cloudflare module allows me to clear related links based on a single post id. In my case, there is significant overlap between the related posts. Causes many extra requests to clear urls.
Solution: Allow for either a postId or postIds array to be process by Hooks purgeCacheByRelevantURLs. Aggregate all related links and apply array_unique to only clear overlapping urls once.
Results:
For 24 products (posts) that need their related links cleared, pull request reduces the amount of API requests from 31 to 7 (442% decrease) and the amount of individuals chunked urls that need to be cleared from 902 to 192. This is for a forced https site, non forced https sites would double that amount.