Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.59k stars 799 forks source link

Preload deleting all existing cached files and not creating any #35225

Closed wcruz-br closed 7 months ago

wcruz-br commented 9 months ago

Impacted plugin

Super Cache

Quick summary

Running in a Docker container with Alpine Linux, Apache 2, Wordpress 6.4.2, PHP-FPM 8.3. When preload starts, instead of creating cache files it just erases everything, path by path, at the moment where it should create the files there. No new file is created.

Steps to reproduce

  1. Cache any page by visiting it
  2. Check the files where created under wp-content/cache/supercache/sitename/...
  3. Turn on preload and wait the 10 seconds, or start it manually
  4. Look at the filesystem and you will see all cached files disappearing as the preload runs through the site

A clear and concise description of what you expected to happen.

Preload files should be created for all pages. As it works in another setup I have, with Debian and "traditional" PHP (not CGI/PHP-FPM).

What actually happened

All existing cache files being deleted, no new cache files being generated. If a user visit a page after that, cache files are recreated by demand, but whenever the preload runs, all of them are deleted again.

Impact

All

Available workarounds?

No but the platform is still usable

Platform (Simple and/or Atomic)

No response

Logs or notes

First call to a page, creating cache:

16:49:15 197 /2023/12/cop28/ supercache dir: ABSPATH/wp-content/cache/supercache/mysite.com/2023/12/cop28/
 No Super Cache file found for current URL: ABSPATH/wp-content/cache/supercache/mysite.com/2023/12/cop28/index-https.html
 In WP Cache Phase 2
 Setting up WordPress actions
 Created output buffer
 Output buffer callback
 Gzipping buffer.
 Writing gzipped buffer to wp-cache cache file.
 Renamed temp wp-cache file to ABSPATH/wp-content/cache/supercache/mysite.com/2023/12/cop28/wp-cache-fa9fc6228505d8b800ee9deecf2eff7d.php
 Writing gzip content headers. Sending buffer to browser
 wp_cache_shutdown_callback: collecting meta data.
 Writing meta file: ABSPATH/wp-content/cache/supercache/mysite.com/2023/12/cop28/meta-wp-cache-fa9fc6228505d8b800ee9deecf2eff7d.php

Second call, serving wp-cache:

16:51:51 196 /2023/12/cop28/ supercache dir: ABSPATH/wp-content/cache/supercache/mysite.com/2023/12/cop28/
 wp-cache file exists: ABSPATH/wp-content/cache/supercache/mysite.com/2023/12/cop28/wp-cache-fa9fc6228505d8b800ee9deecf2eff7d.php
 GZIP headers found. Serving compressed output.
 Sending Header: Content-Type: text/html; charset=UTF-8
 Sending Header: Link: <https://mysite.com/wp-json/>; rel="https://api.w.org/", <https://mysite.com/wp-json/wp/v2/posts/38590>; rel="alternate"; type="application/json", <https://mysite.com/?p=38590>; rel=shortlink
 Sending wp-cache file to browser: ABSPATH/wp-content/cache/supercache/mysite.com/2023/12/cop28/wp-cache-fa9fc6228505d8b800ee9deecf2eff7d.php
 exit request

Another user first call to same page, creating and serving supercache:

16:52:31 196 /2023/12/cop28/ supercache dir: ABSPATH/wp-content/cache/supercache/mysite.com/2023/12/cop28/
 No Super Cache file found for current URL: ABSPATH/wp-content/cache/supercache/mysite.com/2023/12/cop28/index-https.html
 wp_cache_get_cookies_values: return:
 In WP Cache Phase 2
 Setting up WordPress actions
 Created output buffer
 wpcache_do_rebuild: doing rebuild for ABSPATH/wp-content/cache/supercache/mysite.com/2023/12/cop28/
 wpcache_do_rebuild: base file found: ABSPATH/wp-content/cache/supercache/mysite.com/2023/12/cop28/meta-wp-cache-fa9fc6228505d8b800ee9deecf2eff7d.php
 wpcache_do_rebuild: base file found: ABSPATH/wp-content/cache/supercache/mysite.com/2023/12/cop28/wp-cache-fa9fc6228505d8b800ee9deecf2eff7d.php
 Output buffer callback
 Anonymous user detected. Only creating Supercache file.
 Gzipping buffer.
 Writing non-gzipped buffer to supercache file.
 Writing gzipped buffer to supercache file.
 Renamed temp supercache file to ABSPATH/wp-content/cache/supercache/mysite.com/2023/12/cop28/index-https.html
 Renamed temp supercache gz file to ABSPATH/wp-content/cache/supercache/mysite.com/2023/12/cop28/index-https.html.gz
 Writing gzip content headers. Sending buffer to browser
 wp_cache_shutdown_callback: collecting meta data.
 Did not write meta file: meta-wp-cache-b435c9c9a75db9b85b113c95f4dd025e.php
supercacheonly: 1
wp_cache_not_logged_in: 2
new_cache:1

Preload run deleting all these files:

17:07:41 207 /wp-cron.php?doing_wp_cron=1706029661.6833810806274414062500 wp_cron_preload_cache: got 10 posts from position 0
 /wp-cron.php?doing_wp_cron=1706029661.6833810806274414062500 supercache dir: ABSPATH/wp-content/cache/supercache/mysite.com/2023/12/cop28/
 /wp-cron.php?doing_wp_cron=1706029661.6833810806274414062500 clear_post_supercache: post_id: 38590. deleting files in ABSPATH/wp-content/cache/supercache/mysite.com/2023/12/cop28/
 /wp-cron.php?doing_wp_cron=1706029661.6833810806274414062500 prune_super_cache: deleted ABSPATH/wp-content/cache/supercache/mysite.com/2023/12/cop28/meta-wp-cache-fa9fc6228505d8b800ee9deecf2eff7d.php
 /wp-cron.php?doing_wp_cron=1706029661.6833810806274414062500 prune_super_cache: deleted ABSPATH/wp-content/cache/supercache/mysite.com/2023/12/cop28/wp-cache-fa9fc6228505d8b800ee9deecf2eff7d.php
 /wp-cron.php?doing_wp_cron=1706029661.6833810806274414062500 prune_super_cache: deleted ABSPATH/wp-content/cache/supercache/mysite.com/2023/12/cop28/index-https.html
 /wp-cron.php?doing_wp_cron=1706029661.6833810806274414062500 prune_super_cache: deleted ABSPATH/wp-content/cache/supercache/mysite.com/2023/12/cop28/index-https.html.gz
 /wp-cron.php?doing_wp_cron=1706029661.6833810806274414062500 wp_cron_preload_cache: fetched https://mysite.com/2023/12/cop28/

Things I already did try:

WP Super Cache Config: temp temp2 temp3

donnchawp commented 7 months ago

I couldn't replicate what you're seeing, although I used the Jetpack Docker, but it has a similar stack.

What you're seeing in the last log is the following:

  1. Preload deletes any existing cached files for a post or page.
  2. It fetches a fresh copy of the page, but only for anonymous users. Those users that don't have a cookie and aren't logged in.

If things were working correctly, you should have seen https://mysite.com/2023/12/cop28/ being loaded before the line that says it's fetching it. Maybe your webserver can't call itself?

Are you still working in this Docker image?

wcruz-br commented 7 months ago

Hi! Thank you for answering this. I'm still working with this setup and I created a shell script to "preload" all pages (calling them from sitemap listing). If I can help doing some specific test, or need more information about this setup, just ask it.

wcruz-br commented 7 months ago

I just tested it with the latest plugin version and it seems to be working fine now. It is preloading all pages as I write this. There are thousands to generate, once it's finished I'll check if it worked as expected and close the ticket if that's the case. Hold on...

wcruz-br commented 7 months ago

It worked like a charm, I'm closing the ticket. Thank you for your time anyway!