Closed KinG-InFeT closed 2 years ago
See conversation at https://github.com/wp-media/wp-rocket/issues/4638#issuecomment-1011429544.
We may want to add Last-Modified
and ETag
as signals for whether page caching is enabled. It's true that this is not 100% indicative of page caching being active, but it's also true that Expires
/Cache-Control
are not 100% indicative either.
Also, along with Age
we may need to add some host-specific headers to sniff for page caching, including X-Cache
, CF-Cache-Status
, X-Kinsta-Cache
, X-Cache-Enabled
/X-Cache-Disabled
, etc. We should re-check the various plugins in the directory to find any such custom headers, and then also look at popular hosts to see what they are sending back. Lastly, a full list of response headers could be obtained from HTTP Archive.
Also consider checking if advanced-cache.php
is present as an adequate signal.
See https://github.com/wp-media/wp-rocket/issues/4638#issuecomment-1012543999:
The only sensible timing-based check seems to me to re-fetch the homepage 3 times, and if any of them response in less than 200ms then we can presume a page cache is responsible for such a “fast” response, or else the site is fast enough that page caching is not necessary. PageSpeed Insights recommends a TTFB under 200ms.
So I'd say we change the test so that instead of checking for page caching we instead check for the need for page caching. As part of that we:
- Check for a <200ms response
- Check for one of the recognized response headers for page caching.
The test results would then be as follows:
<200ms response Page caching detected Test Result Yes Yes Good Yes No Recommended No No Critical In the second case, this catches the case where your site responds just fine when it is getting little traffic. But if the site lacks page caching, it can quickly crash if no page caching is in place.
Successful detection of page caching includes the following, where if any condition is true the rest are skipped:
advanced-cache.php
drop-in is present, enable_loading_advanced_cache_dropin
filter returns true, and WP_CACHE
is true. (New)Cache-Control
response header is present and has a non-zero max-age
. (Existing)Expires
response header is present and has a future value. (Existing)Last-Modified
or ETag
response headers are present (New)Age
response header header is present. (Existing)X-Cache
, X-Proxy-Cache
, X-Kinsta-Cache
, CF-Cache-Status
, CF-Apo-Via
, etc. (New)I suggest the existing \AmpProject\AmpWP\Admin\SiteHealth::check_for_page_caching()
method be changed so that instead of returning a bool
it returns an array that contains three:
advanced_cache_present
(bool) — WP_CACHE && apply_filters( 'enable_loading_advanced_cache_dropin', true ) && file_exists( WP_CONTENT_DIR . '/advanced-cache.php' )
page_caching_response_headers
(array) — a list of the headers that were detected to indicate page caching is enabledresponse_timing
(array) — list of the response times in millisecondsThese three data points can then be used to determine whether the test is in the Good, Recommended, or Critical state. It can also be used to show the user the results of the test (displaying the values returned by that method).
For response_timing
, the test is considered a pass if one of the values are less than 200ms.
PageSpeed Insights recommends a TTFB under 200ms.
This seems out of date. The current audit mentions a target of 100ms: https://github.com/GoogleChrome/lighthouse/blob/82772f93645989c9c250c78a0ad10d55f3372beb/lighthouse-core/audits/server-response-time.js#L27-L30
The web.dev article mentions the audit failing if it takes more than 600ms to load the main document: https://web.dev/time-to-first-byte/
It's probably unreasonable for page caching plugins on shared hosts to get <200ms responses. So 600ms would probably be better, and since it aligns with PageSpeed Insights.
In regards to the 3-iteration loop in check_for_page_caching
, instead of short-circuiting when it finds the first page caching response header present, it should instead continue iterating (up to 3 times) until it gets a sub-600ms response. (Alternatively, it could always do 3 iterations and then the median response time could be used for the test results as opposed to the minimum.)
@KinG-InFeT Would you be willing to test the improvement in the latest 2.2.x production build?
@KinG-InFeT Would you be willing to test the improvement in the latest 2.2.x production build?
yes, now Site Health not return the error for cache 👍
Bug Description
detect cache plugin not work correctly, please see this ticket: https://github.com/wp-media/wp-rocket/issues/4638
Expected Behaviour
detect cache plugin correctly
Screenshots
No response
PHP Version
7.4.21 (fpm)
Plugin Version
2.2
AMP plugin template mode
Transitional
WordPress Version
5.8.3
Site Health
`
wp-core
version: 5.8.3 site_language: it_IT user_language: it_IT timezone: Europe/Rome permalink: /%postname%/ https_status: true multisite: false user_registration: 1 blog_public: 1 default_comment_status: open environment_type: production user_count: 461 dotorg_communication: true
wp-paths-sizes
wordpress_path: /var/www/programmiedovetrovarli wordpress_size: loading... uploads_path: /var/www/programmiedovetrovarli/wp-content/uploads uploads_size: loading... themes_path: /var/www/programmiedovetrovarli/wp-content/themes themes_size: loading... plugins_path: /var/www/programmiedovetrovarli/wp-content/plugins plugins_size: loading... database_size: loading... total_size: loading...
wp-dropins (2)
advanced-cache.php: true object-cache.php: true
wp-active-theme
name: Neve Child (neve-child-master) version: 1.0.0 author: ThemeIsle author_website: https://themeisle.com parent_theme: Neve (neve) theme_features: core-block-patterns, hfg_support, widgets-block-editor, title-tag, post-thumbnails, automatic-feed-links, custom-logo, html5, customize-selective-refresh-widgets, custom-background, align-wide, editor-color-palette, fl-theme-builder-headers, fl-theme-builder-footers, fl-theme-builder-parts, header-footer-elementor, lifterlms-sidebars, lifterlms, service_worker, starter-content, amp, menus, widgets theme_path: /var/www/programmiedovetrovarli/wp-content/themes/neve-child-master auto_update: Disabilitato
wp-parent-theme
name: Neve (neve) version: 3.1.3 author: ThemeIsle author_website: https://themeisle.com theme_path: /var/www/programmiedovetrovarli/wp-content/themes/neve auto_update: Disabilitato
wp-themes-inactive (1)
Twenty Twenty-One: version: 1.4, author: the WordPress team, Aggiornamenti automatici abilitati
wp-plugins-active (23)
Ad Inserter Pro: version: 2.7.8, author: Ad Inserter Pro, Aggiornamenti automatici disabilitati Akismet Anti-Spam: version: 4.2.1, author: Automattic, Aggiornamenti automatici disabilitati AMP: version: 2.2.0, author: AMP Project Contributors, Aggiornamenti automatici disabilitati Autoptimize: version: 2.9.5, author: Frank Goossens (futtta), Aggiornamenti automatici disabilitati GDPR Cookie Consent: version: 2.0.7, author: WebToffee, Aggiornamenti automatici disabilitati Google Adsense Pages Violation Check: version: 1.0.0, author: Vincenzo Luongo, Aggiornamenti automatici disabilitati Ko-fi Button: version: 1.0.3, author: Ko-fi Team; www.ko-fi.com, Aggiornamenti automatici disabilitati Manage Notification E-mails: version: 1.8.2, author: Virgial Berveling, Aggiornamenti automatici disabilitati Newsletter, SMTP, Email marketing and Subscribe forms by Sendinblue: version: 3.1.30, author: Sendinblue, Aggiornamenti automatici disabilitati Ninja Forms: version: 3.6.7, author: Saturday Drive, Aggiornamenti automatici disabilitati Redirection: version: 5.1.3, author: John Godley, Aggiornamenti automatici disabilitati Redis Object Cache: version: 2.0.22, author: Till Krüss, Aggiornamenti automatici disabilitati Site Kit by Google: version: 1.48.1, author: Google, Aggiornamenti automatici disabilitati Super Progressive Web Apps: version: 2.2, author: SuperPWA, Aggiornamenti automatici disabilitati UpdraftPlus - Backup/Restore: version: 1.16.69, author: UpdraftPlus.Com, DavidAnderson, Aggiornamenti automatici disabilitati WebP Express: version: 0.25.0, author: Bjørn Rosell, Aggiornamenti automatici disabilitati WP Adsterra Dashboard: version: 1.2.2, author: Vincenzo Luongo, Aggiornamenti automatici disabilitati wpDiscuz: version: 7.3.9, author: gVectors Team, Aggiornamenti automatici disabilitati WP Rocket: version: 3.10.6, author: WP Media, Aggiornamenti automatici disabilitati WP ShrtFly Integration: version: 1.0.0, author: Vincenzo Luongo, Aggiornamenti automatici disabilitati WP Telegram: version: 3.1.7, author: WP Socio, Aggiornamenti automatici disabilitati Yoast Duplicate Post: version: 4.3, author: Enrico Battocchi & Team Yoast, Aggiornamenti automatici disabilitati Yoast SEO: version: 17.9, author: Team Yoast, Aggiornamenti automatici disabilitati
wp-media
image_editor: WP_Image_Editor_Imagick imagick_module_version: 1687 imagemagick_version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org imagick_version: 3.4.4 file_uploads: File uploads is turned off post_max_size: 512M upload_max_filesize: 512M max_effective_size: 512 MB max_file_uploads: 200 imagick_limits: imagick::RESOURCETYPE_AREA: 122 MB imagick::RESOURCETYPE_DISK: 1073741824 imagick::RESOURCETYPE_FILE: 768 imagick::RESOURCETYPE_MAP: 512 MB imagick::RESOURCETYPE_MEMORY: 256 MB imagick::RESOURCETYPE_THREAD: 1 imagemagick_file_formats: 3FR, AAI, AI, ART, ARW, AVI, AVS, BGR, BGRA, BGRO, BIE, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CRW, CUR, CUT, DATA, DCM, DCR, DCX, DDS, DFONT, DNG, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, FAX, FILE, FITS, FRACTAL, FTP, FTS, G3, G4, GIF, GIF87, GRADIENT, GRAY, GROUP4, H, HALD, HDR, HISTOGRAM, HRZ, HTM, HTML, HTTP, HTTPS, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, JBG, JBIG, JNG, JNX, JPE, JPEG, JPG, JPS, JSON, K25, KDC, LABEL, M2V, M4V, MAC, MAGICK, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MTV, MVG, NEF, NRW, NULL, ORF, OTB, OTF, PAL, PALM, PAM, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, PPM, PREVIEW, PS, PS2, PS3, PSB, PSD, PTIF, PWP, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGBA, RGBO, RGF, RLA, RLE, RMF, RW2, SCR, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, SUN, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIFF, VIPS, VST, WBMP, WMV, WPG, X, X3F, XBM, XC, XCF, XPM, XPS, XV, XWD, YCbCr, YCbCrA, YUV gd_version: 2.3.0 gd_formats: GIF, JPEG, PNG, WebP, BMP, XPM ghostscript_version: not available
wp-server
server_architecture: Linux 5.4.0-92-generic x86_64 httpd_software: Apache/2.4.41 (Ubuntu) php_version: 7.4.21 64bit php_sapi: fpm-fcgi max_input_variables: 10000 time_limit: 999 memory_limit: 2048M max_input_time: -1 upload_max_filesize: 512M php_post_max_size: 512M curl_version: 7.68.0 OpenSSL/1.1.1f suhosin: false imagick_availability: true pretty_permalinks: true htaccess_extra_rules: true
wp-database
extension: mysqli server_version: 8.0.27-0ubuntu0.20.04.1 client_version: mysqlnd 7.4.21
wp-constants
WP_HOME: undefined WP_SITEURL: undefined WP_CONTENT_DIR: /var/www/programmiedovetrovarli/wp-content WP_PLUGIN_DIR: /var/www/programmiedovetrovarli/wp-content/plugins WP_MEMORY_LIMIT: 40M WP_MAX_MEMORY_LIMIT: 2048M WP_DEBUG: false WP_DEBUG_DISPLAY: false WP_DEBUG_LOG: false SCRIPT_DEBUG: false WP_CACHE: true CONCATENATE_SCRIPTS: undefined COMPRESS_SCRIPTS: undefined COMPRESS_CSS: undefined WP_LOCAL_DEV: undefined DB_CHARSET: utf8 DB_COLLATE: undefined
wp-filesystem
wordpress: writable wp-content: writable uploads: writable plugins: writable themes: writable mu-plugins: writable
neve
api: Sì child: /var/www/programmiedovetrovarli/wp-content/themes/neve-child-master/functions.php,
/var/www/programmiedovetrovarli/wp-content/themes/neve-child-master/images/stripe.png,
/var/www/programmiedovetrovarli/wp-content/themes/neve-child-master/images/dark_wall.jpg,
/var/www/programmiedovetrovarli/wp-content/themes/neve-child-master/images/crypto-logos/,
/var/www/programmiedovetrovarli/wp-content/themes/neve-child-master/screenshot.png,
/var/www/programmiedovetrovarli/wp-content/themes/neve-child-master/style.css customizer_css: body { background: url("/wp-content/themes/neve-child-master/images/dark_wall.jpg"); box-shadow: 0 1px 3px rgba(0, 0, 0, .5), inset 0 1px 1px rgba(255, 255, 255, .2);
} .wp-block-search__input, .ninja-forms-field, .search-field { color: black !important; }
footer, .single-page-container, .single-post-container { box-shadow: 0 1px 3px rgba(0, 0, 0, .5), inset 0 1px 1px rgba(255, 255, 255, .2); box-sizing: border-box; outline: 0; -webkit-text-size-adjust: 100%; }
.site-logo h1, .site-logo p { font-size: 1.5em; }
.wp-block-latest-posts.is-grid li , .nv-page-title-wrap.nv-big-title .nv-page-title h1{ text-align: center; }
ul.cbd-classic-list li { float:left; }
.cbd-classic-list h2.CDBBC-title, .cbd-classic-list .cdbbc_tag { color: #222 !IMPORTANT; }
.hfg_header .header-main-inner {
}
.hfg_header .header-main-inner:before{ /z-index: -1;/ background: url("/wp-content/themes/neve-child-master/images/stripe.png") top left; background-repeat: repeat; border: 1px solid #000; width: 100%; height: 100%; position: absolute; top: 0; left: 0; display: block!important; content: ''; }
.floatingchat-container-wrap { bottom: 200px !important; }
google-site-kit
version: 1.48.1 php_version: 7.4.21 wp_version: 5.8.3 reference_url: https://www.programmiedovetrovarli.it amp_mode: secondary site_status: connected-site user_status: authenticated verification_status: verified-non-site-kit connected_user_count: 1 active_modules: site-verification, search-console, adsense, analytics, analytics-4, pagespeed-insights required_scopes: openid: ✅ https://www.googleapis.com/auth/userinfo.profile: ✅ https://www.googleapis.com/auth/userinfo.email: ✅ https://www.googleapis.com/auth/siteverification: ✅ https://www.googleapis.com/auth/webmasters: ✅ https://www.googleapis.com/auth/adsense.readonly: ✅ https://www.googleapis.com/auth/analytics.readonly: ✅ capabilities: googlesitekit_authenticate: ✅ googlesitekit_setup: ✅ googlesitekit_view_posts_insights: ✅ googlesitekit_view_dashboard: ✅ googlesitekit_view_module_details: ✅ googlesitekit_manage_options: ✅ enabled_features: dashboardSharing: ⭕ ideaHubModule: ⭕ serviceSetupV2: ⭕ swgModule: ⭕ userInput: ⭕ unifiedDashboard: ⭕ search_console_property: https://www.programmiedovetrovarli.it/ adsense_account_id: pub-502••••••••••••• adsense_client_id: ca-pub-502••••••••••••• adsense_account_status: approved adsense_use_snippet: yes adsense_web_stories_adunit_id: none analytics_account_id: 4069•••• analytics_property_id: UA-4069•••••• analytics_profile_id: 7210•••• analytics_use_snippet: yes analytics_4_property_id: none analytics_4_web_data_stream_id: none analytics_4_measurement_id: none analytics_4_use_snippet: yes
amp_wp
amp_slug_query_var: amp amp_slug_defined_late: false amp_mode_enabled: transitional amp_reader_theme: legacy amp_templates_enabled: post, page, is_singular, is_front_page, is_home, is_archive, is_author, is_date, is_search, is_404, is_category, is_tag amp_serve_all_templates: true amp_css_transient_caching_disabled: n/a amp_css_transient_caching_threshold: 5000 transients per day amp_css_transient_caching_sampling_range: 14 days amp_css_transient_caching_transient_count: 783 amp_css_transient_caching_time_series: 20210928: 764 20210929: 780 20210930: 580 20211001: 723 20211002: 762 20211003: 772 20211004: 773 20211005: 777 20211006: 779 20211007: 697 20211008: 749 20211009: 772 20211010: 778 20211011: 783 amp_libxml_version: 2.9.12
`
Gutenberg Version
No response
OS(s) Affected
VPS Linux
Browser(s) Affected
All
Device(s) Affected
All
Acceptance Criteria
No response
Implementation Brief
No response
QA Testing Instructions
No response
Demo
No response
Changelog Entry
No response