cloudflare / Cloudflare-WordPress

A Cloudflare plugin for WordPress
https://www.cloudflare.com/wordpress/
BSD 3-Clause "New" or "Revised" License
215 stars 83 forks source link

WordPress REST API not purged on new post or updates #248

Open rmens opened 5 years ago

rmens commented 5 years ago

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

AJB99 commented 4 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:

image

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: $$$$).

garrettgalow commented 4 years ago

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.

jabranr commented 4 years ago

@garrettgalow is this something to be considered as potential new feature? I might be able to look into this and send a PR.

rmens commented 4 years ago

@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.

garrettgalow commented 4 years ago

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.

markjaquith commented 3 years ago

This issue could use a second look now that APO is in the picture.

rmens commented 3 years ago

Yes. I wonder if @garrettgalow was referring to APO as what was in the works.

github-actions[bot] commented 3 years ago

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.

rmens commented 3 years ago

Still curious if this is fixed by enabling APO.

davidpelayo commented 2 years ago

Is there any PR or activity that aims to fix this issue anytime soon?

alyxb commented 2 years ago

Has this been resolved?

rmens commented 2 years ago

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.

physixfan commented 2 years ago

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.

physixfan commented 2 years ago

@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!

physixfan commented 2 years ago

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?

Jineshpanchal commented 1 year ago

We have ben facing this issue since more than few month but not yet address.

https://community.cloudflare.com/t/since-past-2-days-pages-are-not-updated-and-served-from-cached-even-after-clearing-cache/411786

https://support.cloudflare.com/hc/en-us/requests/2530764?page=1

apsjohn commented 1 year ago

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?

github-actions[bot] commented 1 year ago

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.

rmens commented 1 year ago

After two years I’m still curious if this is fixed by enabling APO.

ned-bs commented 1 year ago

same here

github-actions[bot] commented 10 months ago

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.

rmens commented 10 months ago

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.

ned-bs commented 10 months ago

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?

rmens commented 10 months ago

@bsahins Sorry i’m in publishing. It only works for posts not for e-commerce.

ned-bs commented 10 months ago

@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.

rmens commented 10 months ago

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.

github-actions[bot] commented 4 months ago

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.

rmens commented 4 months ago

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.

ned-bs commented 4 months ago

same for product price and stock updates. They just don't care.

ned-bs commented 2 months ago

5 years and no reply.