BoldGrid / w3-total-cache

GNU General Public License v2.0
152 stars 85 forks source link

Bug: Cache Preloading not always kicking in after cache purge from publishing event #687

Closed porg closed 7 months ago

porg commented 1 year ago

I debugged W3TC 's Cache Preload feature intensively over the weekend & came to these findings:

  1. Cache Preload's initial buildup from Automatically prime the page cache works fine.
    • Both after clicking Save Settings & Purge Caches in the settings.
    • or a manual SSH/FTP deletion of /wp-content/cach/page_enhanced/domain-directory/.
  2. But Preload the post cache upon publish events works not reliably. In some tests it kicked in:
    • ✅ reliably within what I calculated as the total Preloading Loop Duration (see in: Debugging Setup)
      • though still too late to make a difference for editors, better would be:

        686

    • ❌ not at all, also not hours later.

My suspicion

My Website Usability and Performance Goals

My Environment + My Goals in full there and summarized here:

  1. Don’t want the first visitor of a new or purged cached page to await page cache generation. Hence:
    • a) ☑︎ Automatically prime the page cache
    • b) ☑︎ Preload the post cache upon publish events
  2. Want my users to always have a chance to get the most recent version of a page/post. Hence:
    • Browser Cache → HTML/XML → Cache-Policy: “cache with validation”
      • PRO: Reliably always get most recent content with only a minimal overhead: One roundtrip of HTTP metadata exchange, no content download if unchanged.

Debugging Setup

Preloading Loop Duration: 30 URLs in batches of 5 = 6 batches total * 15secs per batch = 90secs = 1.5 mins

Video Recording

Window setup used throughout the video:

W3TC--00-Preload-Cache

Nicely documented

Alternative: Each chapters as standalone video file

01 Windows and Setup Explained

https://user-images.githubusercontent.com/737143/236892106-c6108684-31e4-4488-a863-9c4ed55e5cde.mov

02 Edited then Purged but Preloading never

https://user-images.githubusercontent.com/737143/236891249-7074b0d1-f3d3-404f-9fb6-97a6ea2071aa.mov

03 Cached pages outside of sitemap overnight

https://user-images.githubusercontent.com/737143/236892329-c6adcb3a-56e2-4bd6-9fe3-1b301bb15558.mov

04 Deleting entire domain page cache then observing one full Cache Preload cycle

https://user-images.githubusercontent.com/737143/236891470-b3ba3fdc-d7bd-4ed6-9d74-c5b62b9ab1ae.mov

05 Edited then Purged then Preloading worked

https://user-images.githubusercontent.com/737143/236891688-9c3e32e6-4119-43d1-a463-ea1428a6f5d3.mov

06 Observing Preloading in Command Line with wp-cli

https://user-images.githubusercontent.com/737143/236897916-e4645611-d434-4323-a118-b537375c93ea.mp4

porg commented 1 year ago

I'd appreciate to get a response to this!

If you don't have the time to read the original report, let's make it short:

Besides all the debugging I still recommend to give the recreation of a purged page utmost priority (temporarily queue in the updates page(s) in another "urgent preload loop", or temporarily change the main loop offset to there, and then back to the last offset number), however you may do that technically, as I proposed in:

porg commented 1 year ago

After updating /my-page/ I do not want to perform any of these workarounds:

This should work more intelligently. Regenerate what was recently purged. I mean that priority is really obvious. Please.

porg commented 7 months ago

So my report has been confirmed as reproducible? And the symptoms could be fixed?

cssjoe commented 7 months ago

@porg This issue has been attached to a pull request that was merged and is staged to be released in W3 Total Cache 2.7.2. We have added a couple of settings that can be enabled to prime the cache for pushed and updated posts/pages.