Opened 6 months ago
Last modified 3 weeks ago
#62101 new enhancement
Add a filter to customize the URL for page caching check in Site Health
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 6.1 |
Component: | Site Health | Keywords: | has-patch has-unit-tests |
Focuses: | performance | Cc: |
Description
In the check_for_page_caching function, which is used to check if a page is being cached in the Site Health panel, the request is made to the URL returned by home_url( '/' ). This limits the caching check to the homepage only.
I propose adding a filter apply_filters( 'site_status_persistent_page_cache_url', home_url( '/' ) ) that would allow developers to modify the URL used to check for caching. This would provide more flexibility in checking the caching status of different pages and scenarios.
<?php $caching_url = apply_filters( 'site_status_persistent_page_cache_url', home_url( '/' ) ); $http_response = wp_remote_get( $caching_url, compact( 'sslverify', 'headers' ) );
Benefits:
- Flexibility in caching checks:
This allows checking the caching status of any page on the site, not just the homepage. It can be useful for sites where specific pages (like product catalogs or popular posts) experience high traffic.
- Support for multilingual sites:
For multilingual sites, this enables checking the caching of different language versions, ensuring proper caching across all localized versions.
- Testing and debugging:
In testing and development environments, you can configure caching checks for test pages without affecting the homepage.
- Dynamic URL modification:
Depending on conditions (time of day, user type, site configuration), the URL for caching checks can be dynamically altered, providing deeper insights into caching performance.
- External caching systems check:
The filter can be used to check caching at the CDN level or other external proxy systems, which is especially useful for sites leveraging Cloudflare or other external caching systems.
Conclusion:
The proposal to add a filter for customizing the URL in the page caching check within the Site Health panel offers more flexible and adaptable options for administrators and developers. It enhances control over caching, both at the system and external caching levels, and allows tailoring checks for specific site pages based on their importance.
Change History (11)
This ticket was mentioned in PR #7426 on WordPress/wordpress-develop by @zetrider.
6 months ago
#1
#2
@
6 months ago
- Focuses administration removed
- Version set to 6.1
Full page health check introduce in #56041.
Left some initial feedbacks.
@martin.krcho commented on PR #7426:
2 months ago
#3
@zetrider could you address the outstanding feedback? It's couple of small things and I believe this could be ready for merge.
@mukesh27 commented on PR #7426:
2 months ago
#4
@zetrider could you address the outstanding feedback? It's couple of small things and I believe this could be ready for merge.
Yes. Once the feedback addressed i will approve and move the ticket in 6.8 milestone for visibility
@zetrider commented on PR #7426:
2 months ago
#5
Thanks guys, good catch, done.
#6
@
2 months ago
- Milestone changed from Awaiting Review to 6.8
Move into 6.8
milestone for visibility.
#7
@
2 months ago
Thank you for opening the ticket @zetrider!
While the pull request looks on a good path for what you are proposing as a solution, I am wondering whether that's the right approach.
I agree that it would be useful to check for page caching on other URLs. But is it really a good idea that whichever other URL should replace checking on the home page? Wouldn't it be a more desirable solution to be able to provide additional URLs via filter?
This ticket was mentioned in Slack in #core-test by oglekler. View the logs.
2 months ago
#9
@
2 months ago
While I agree with introducing this filter, I am concerned about the potential risks of accepting any URL. To mitigate these risks, I would prefer to limit the filter to local URLs still using home_url().
Here's an example of how this could be implemented:
<?php $caching_path = apply_filters( 'site_status_persistent_page_cache_path', '/' ); $http_response = wp_remote_get( home_url( $caching_path ), compact( 'sslverify', 'headers' ) );
What do you think about implementing it this way?
Trac ticket: https://core.trac.wordpress.org/ticket/62101