Comments (5)
Nice! blogid
is just an arbitrary string, there's no standard way, you can really flag a cached entry with any string you like, as long as it can be successfully encoded to an decoded from JSON, it should be ok.
from surge.
@MadtownLems you can use Surge\flag()
to set specific flags when a page is being rendered, for example if it's rendered using block-1, block-2 and block-3, you can add those flags to the request, then use Surge\expire()
to expire block-1 when it's updated, which would invalidate all pages with that flag.
There are some examples in the existing invalidation routines: https://github.com/kovshenin/surge/blob/main/include/invalidate.php
Hope that helps!
from surge.
Hope that helps!
I wish it did 😅
I've taken a look at invalidate.php many times now (as well as https://konstantin.blog/2021/wordpress-cache-invalidation-with-flags/ ) and still have no idea how I might use Surge\flag().
We have Surge network activated on a MultiSite network, and what I'm really trying to do is figure out a way to clear a single subsite's entire cache on certain events.
I've also been looking at /wp-content/cache/surge/flags.json.php and am trying to understand how the flags stored in this file differentiate between sites in the multisite 🤔
Any insights you can provide would be much appreciated. 🙏
from surge.
@MadtownLems here's an example:
// Flag each entry with the current blog id.
add_action( 'template_redirect', function() {
Surge\flag( sprintf( 'blogid:%d', get_current_blog_id() ) );
} );
// Expire all subsite cache on certain events.
add_action( 'certain_event', function() {
Surge\expire( sprintf( 'blogid:%d', get_current_blog_id() ) );
} );
from surge.
here's an example:
Perfect! Exactly what I was looking for. I had no idea that "blogid:" was a valid flag, as I didn't see it anywhere else in invalidate.php.
Question: Are the available flags some standard thing that I can read about somewhere?
from surge.
Related Issues (20)
- Theme conflict, null on WooCommerce product titles HOT 1
- Can't clean `php://input`
- Preloading pages HOT 1
- Enable cache for logged in users HOT 2
- Manipulating PHP globals HOT 1
- PHP warnings HOT 2
- <!-- served by Surge: timestamp --> HOT 2
- Add support for content negotiation HOT 5
- ACF content doesn't load on custom taxonomies HOT 1
- It seems Health in WP does not see the caching header HOT 2
- Conflict with Shibboleth SSO; use on select sites in MultiSite? HOT 2
- PHP error logs have numerous: stat failed... HOT 1
- Add filter to disable invalidation
- Getting these errors...
- Issue with the ActivityPub plugin HOT 2
- MultiSite Questions HOT 5
- Feature Request: Make $flush_actions filterable
- PHP Warning: flock() expects parameter 1 to be resource, bool given
- Support hosts that disable fpassthru()
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from surge.