Open rmens opened 5 years ago
I've run into this same issue using WP as a headless CMS with a Vue.js frontend that makes XHR requests to https://wp.mysite.com/wp-json/*
to fetch post, page, media, etc data.
I'm attempting to use a Cloudflare Page Rule to cache all responses from requests made to wp.mysite.com/wp-json/*
, but the Cloudflare Wordpress plugin is failing to purge the cache for that Page Rule when any content (post, page, media, etc.) is updated via my WP Admin Console.
These are my Page Rule settings:
If I remove the "Edge Cache TTL" setting then I'm seeing that Cloudflare always sends the request to my source server. But if I enable it (and it does cache responses from the /wp-json/*
URL) then the cache is not purged via the Cloudflare WP Plugin when I make updates to my content.
A response from @Cloudflare-Wordpress would be appreciated. This is a significant limitation that Cloudflare needs to address for customers looking to implement a headless WP CMS and use Cloudflare to make it reasonably fast. Headless WP essentially requires Cloudflare (Read: $$$$).
Unfortunately, this functionality isn't supported by our plugin. The plugin purges cache on updates to the style of the site like theme changes. The plugin does not purge .html content, given that our default behavior is not to cache such content.
@garrettgalow is this something to be considered as potential new feature? I might be able to look into this and send a PR.
@jabranr As fellow user I would say a PR would be nice anyway. This plug-in is not updated that often so running a fork that integrates this is doable. If it's merged switching back to the official plug-in is always an option.
I believe we have something in the works that is going to address this. However, the plugin by default will not support this, as its not built to handle all content being cached.
This issue could use a second look now that APO is in the picture.
Yes. I wonder if @garrettgalow was referring to APO as what was in the works.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Still curious if this is fixed by enabling APO.
Is there any PR or activity that aims to fix this issue anytime soon?
Has this been resolved?
Not that I'm aware of. This might be fixed with APO, but I don't use that so if someone who uses APO could test it that would be great.
I can confirm we have the same issue: even with the new APO feature, RESI API cache are not purged properly after post updating. We hope some can make a PR or something to resolve this issue.
@garrettgalow is this something to be considered as potential new feature? I might be able to look into this and send a PR.
We would really appreciate your effort if you can add this as a new feature!
The plugin used to have a feature called "Auto Purge Content On Update" and it worked properly. I am wondering why it is disabled after APO feature is introduced. Can someone in CloudFlare fix this problem?
We have ben facing this issue since more than few month but not yet address.
https://support.cloudflare.com/hc/en-us/requests/2530764?page=1
I am having the same problem, but i dont think its limited on rest api url's only, i have no page purge when updating content on site generally... Tried many things, nothing triggers it even after an hour is passed...
Do you have (for example) a specific product page cache purged when you update that product's price?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
After two years I’m still curious if this is fixed by enabling APO.
same here
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Since this issue has many thumbs up and eyes I'll try to ask again about if APO fixes this. I only have one Wordpress site on a professional plan and am not willing to take the risk of testing this in production so an answer would be appreciated.
In more general terms I'm curious if there is a product manager for APO or WordPress products at Cloudflare. This plug-in seems to get drive-by updates but I haven't seen it improve in meaningful ways the past years. It's odd that the biggest CMS in the world isn't serviced well by Cloudflare.
I don't think anyone from Cloudflare read our comments in here. @rmens you have mentioned that you coded a plugin to purge cache automatically. Does it purge only related product? Could you please share it?
@bsahins Sorry i’m in publishing. It only works for posts not for e-commerce.
@rmens thanks for quick feedback. Actually products are also posts in woocommerce. If your code is working for posts, it will work for products too. It would be great if you can share, I can test and get back to you.
I uploaded the plug-in I use as code snippet on https://gist.github.com/rmens/3fde8d6694418e8038ca4f623a187d3c. Let's not pollute the discussion further here.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Since this issue has garnered much eyes and thumbs, I'll ask again: Does APO fix this? I have one WordPress site on a professional plan and can't risk testing it in production, so I'd appreciate an answer.
More broadly, is there a product manager for APO or WordPress products at Cloudflare? The plugin gets occasional updates, but I haven't seen significant improvements over the years. It's strange that Cloudflare doesn't better support the world's largest CMS.
same for product price and stock updates. They just don't care.
5 years and no reply.
Hi,
I'm using the Cloudflare WordPress plug-in to automatically cache everything on a very high traffic WordPress site and app. The plug-in does a great job purging the cache on creation of a new post and edits, but the REST API doesn't seem to be purged.
I hard-coded a small plug-in to purge the following routes in the Cloudflare API on post update or publish, but this seems to be something that the Cloudflare plug-in should do.
https://domain/wp-json/wp/v2/posts/_the_post_id
https://domain/wp-json/wp/v2/posts