Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can Sunny purge the rss feed on publish? #2

Closed
collinbarrett opened this issue Jan 19, 2016 · 6 comments

Comments

3 participants
@collinbarrett
Copy link

commented Jan 19, 2016

I am still testing this, but it seems like Sunny does not purge the rss feed from CloudFlare's cache when a post is published? I just had a scheduled post automatically get published at it's schedule time, but CloudFlare's cache of my rss feed did not get purged until I manually purged the url of my feed. Just wondering if this is a bug or a feature that needs to be added? Thanks for the great plugin!

Note: This plugin is awesome and I posted an article about it here.
https://collinmbarrett.com/2016/01/07/wordpress-cloudflare-dynamic-cache/

@TangRufus

This comment has been minimized.

Copy link
Member

commented Jan 20, 2016

Thanks for the blog post!

Purging RSS feed URLs are not supported at this version.

If you really need it, there are 2 quick workaround:

  1. Don't add your RSS feeds to cache everything rules, OR
  2. Hook Sunny_Purger::purge_cloudflare_cache_by_url( $url ) to post publish (and other hooks) you need
@collinbarrett

This comment has been minimized.

Copy link
Author

commented Jan 20, 2016

Ok, great, thanks. I've used my max of 3 free Page Rules, so I will look into adding the hook when I have time. Maybe I can submit a pull to the plugin. Thanks for the great work on it.

@collinbarrett

This comment has been minimized.

Copy link
Author

commented Jan 20, 2016

I have not done a ton of WordPress-specific php development. Can you point me in the right direction for where I would put that hook in suggestion #2?

@collinbarrett

This comment has been minimized.

Copy link
Author

commented Feb 24, 2016

I was able to temporarily accomplish this until we get it in a new release of Sunny, via your suggestion, by adding the following to my child theme's functions.php. I need to ensure category feeds are purged instantly as well because I use IFTTT->Buffer->Social Media (social media outlets based on category). Comment and tag feeds aren't critical and can wait until the (in my case) 4-hour timeout for CloudFlare's edge expires.

// purge RSS feed from CloudFlare via Sunny
function purge_rss_cloudflare() {
  Sunny_Purger::purge_cloudflare_cache_by_url( 'https://collinmbarrett.com/feed/' );
  Sunny_Purger::purge_cloudflare_cache_by_url( 'https://collinmbarrett.com/life/feed/' );
  Sunny_Purger::purge_cloudflare_cache_by_url( 'https://collinmbarrett.com/development/feed/' );
  Sunny_Purger::purge_cloudflare_cache_by_url( 'https://collinmbarrett.com/security-privacy/feed/' );
}
add_filter( 'publish_post', 'purge_rss_cloudflare' );
add_filter( 'edit_post', 'purge_rss_cloudflare' );
add_filter( 'delete_post', 'purge_rss_cloudflare' );

I'm keeping this issue flagged, and I hope to be able to help develop this in a future release of Sunny. It really is a very valuable plugin. Thanks.

If Sunny purged all feed, page, post, custom post types, and anything else I'm forgetting, we could bump CloudFlare's edge cache way up to the max. of 1-month on the free plan and visitors would never get a miss on the CF cache unless they are the first visitor to a freshly updated page. #someday

@fgilio

This comment has been minimized.

Copy link

commented Mar 16, 2016

This is great guys, gonna implement it very soon!

@TangRufus

This comment has been minimized.

Copy link
Member

commented Apr 29, 2017

Thank you all!

The new RelatedUrls class now tracks category, tag, author, author feed, post-type-archive and feed.
See: https://github.com/TypistTech/sunny/tree/master/src/Posts/RelatedUrls

This will be shipped with version 2.0.0 release.

Maybe: Add page_for_posts support, see: #7

@TangRufus TangRufus closed this Apr 29, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.