kovshenin / surge

Surge is a very simple and fast page caching plugin for WordPress.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MultiSite Questions

MadtownLems opened this issue · comments

I've been loving the performance improvements that come with Surge, and I've been digging into it more and more. I've got a couple questions, especially as it pertains to MultiSite.

You said that it's supported out of the box (https://wordpress.org/support/topic/multisite-636/). However, the more that I learn about how everything works, I'm wondering if there might be some ways to improve MultiSite performance.

Just for reference, our MultiSites contain several hundred sites - not a small handful.

It seems that if any site on the network does any of the things in $flush_actions, the entire network's cache is immediately invalidated. So, one site changing themes, activating a plugin, etc will expire the cache for several hundred other sites which were not impacted at all by the change. This means our cache is getting expired very frequently, and well in advance of the longer time I'm trying to support.

I was wondering if there's any compelling reason why subsites don't operate more independently. For example, if each subsite maintained its own /wp-content/cache/surge/flags.json.{$blog_id}.php file, and then only flush the cache for the impacted subsite during those actions. Of course, there are still SOME actions that should likely flush the entire network's cache, such as WP itself updating or a plugin being network activated/deactivated.

@MadtownLems great question and i'm also looking to hear the answer!

Hey folks, thanks for bringing this up, definitely an oversight which I've addressed in a recent commit.

Not sure I like the idea of separate flag files. Out of curiosity, how large is your current flags file with the several hundred sites in the network?

Thanks @kovshenin!

Recent commit for references
54f57a6

Out of curiosity, how large is your current flags file with the several hundred sites in the network?

Currently it's only about 200KB, but with you addressing some of my recent issues/requests, I'm expecting that to grow significantly. I've held off on adding my own flags because of how it WAS working in Multisite, where a change on one site would flush the entire network. It didn't seem super necessary to get too aggressive in doing my own flagging, because everything would get invalidated frequently. With the change to Multisite functionality, my plan is to try to keep a relatively long TTL for most pages (as plenty of our sites are actively browsed but basically never updated). The manual flagging should help keep things fresh for the sites that DO have active content changes frequently.

Thank you so much for addressing the Multisite invalidation issue! I'm really excited to take a look at the changes and get these rocking. 🤘

Sounds good! The recent change shouldn't affect the size too much if it's already 200kb, there should be at most as many new flags as the number of sites in the network, so ~ 16 bytes for flag name and ~ 10 bytes for the timestamp (as a string), round to 32 bytes. For 1000 sites that would be + 32kb. I am a bit worried about how long a lookup would take with such a large object though, should probably run some benchmarks! I'd also be curious to know if it grows larger than that!