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

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

Open
rmens opened this issue Sep 12, 2019 · 30 comments
Open

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

rmens opened this issue Sep 12, 2019 · 30 comments

Comments

@rmens
Copy link

rmens commented Sep 12, 2019

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
Copy link

AJB99 commented May 2, 2020

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
Copy link
Contributor

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
Copy link

jabranr commented Sep 16, 2020

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

@rmens
Copy link
Author

rmens commented Sep 16, 2020

@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
Copy link
Contributor

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
Copy link
Contributor

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

@rmens
Copy link
Author

rmens commented Mar 5, 2021

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

@github-actions
Copy link

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.

@github-actions github-actions bot added the Stale label Sep 20, 2021
@rmens
Copy link
Author

rmens commented Sep 20, 2021

Still curious if this is fixed by enabling APO.

@github-actions github-actions bot removed the Stale label Sep 21, 2021
@davidpelayo
Copy link

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

@alyxb
Copy link

alyxb commented Mar 31, 2022

Has this been resolved?

@rmens
Copy link
Author

rmens commented Apr 3, 2022

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
Copy link

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
Copy link

@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
Copy link

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?

@johnaps94
Copy link

johnaps94 commented Jan 9, 2023

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
Copy link

github-actions bot commented Jul 9, 2023

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.

@github-actions github-actions bot added the Stale label Jul 9, 2023
@rmens
Copy link
Author

rmens commented Jul 9, 2023

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

@ned-bs
Copy link

ned-bs commented Jul 9, 2023

same here

@github-actions github-actions bot removed the Stale label Jul 10, 2023
Copy link

github-actions bot commented Jan 7, 2024

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.

@github-actions github-actions bot added the Stale label Jan 7, 2024
@rmens
Copy link
Author

rmens commented Jan 7, 2024

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.

@github-actions github-actions bot removed the Stale label Jan 8, 2024
@ned-bs
Copy link

ned-bs commented Jan 8, 2024

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
Copy link
Author

rmens commented Jan 8, 2024

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

@ned-bs
Copy link

ned-bs commented Jan 8, 2024

@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
Copy link
Author

rmens commented Jan 8, 2024

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.

Copy link

github-actions bot commented Jul 7, 2024

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.

@github-actions github-actions bot added the Stale label Jul 7, 2024
@rmens
Copy link
Author

rmens commented Jul 9, 2024

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
Copy link

ned-bs commented Jul 9, 2024

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

@github-actions github-actions bot removed the Stale label Jul 10, 2024
@ned-bs
Copy link

ned-bs commented Sep 3, 2024

5 years and no reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests